fix(parser): includeパラメータ値内の]]/triple-linkでdirectiveが途切れる問題を修正#43
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wdpr-demo-v1 | fa2cff2 | Commit Preview URL Branch Preview URL |
Jun 04 2026, 11:22 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
decompiler-preview | fa2cff2 | Commit Preview URL Branch Preview URL |
Jun 04 2026, 11:22 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wdpr-demo-v1-files | fa2cff2 | Commit Preview URL Branch Preview URL |
Jun 04 2026, 11:22 AM |
include パラメータ値に nested な [[ ... ]] (例: caption 内の [[span]]...[[/span]]) や単独の ]] が含まれると、従来の正規表現が最初の ]] で directive を切ってしまい、値が途中で途切れて残りが外側に漏れていた。 INCLUDE_PATTERN を廃止し、scanIncludeDirectives に置換: - [[ で depth+1、]] で depth-1 し、depth<=0 の ]] で close。 - ただし close と認めるのは「opener と同一行 (single-line/inline)」または 「行末 (後続が空白のみ)」の ]] のみ。継続行の mid-line ]] (bare/nested) では閉じないため caption 等が途切れない。 - 同一行条件により inline-trailing ([[include x]] text) は opener 行で閉じ、 後続の別 include を巻き込まない。 - close が見つからない opener は未展開のまま据え置き。 - expandIterative / expandIterativeAsync をスキャナベースに書き換え。 test: nested markup / bare ]] / single-line / inline-trailing + 後続 include / triple-link(分離行) / 未バランス opener のケースを追加。
scanIncludeDirectives で `[[[ ... ]]]` を block の `[[`/`]]` とは別の link depth で数えるよう変更。link depth が正のあいだは内部の `[[`/`]]` を literal 扱いし block depth を動かさないため、link の `]]]` が directive の close `]]` と同一行で隣接 (`...|cap=[[[link]]]]]`) しても link が 途切れず再構成される。directive の close 判定は従来どおり block depth の opener 行 / 行末ルールのみに依存し、隣接する別 directive を巻き込まない。
r74tech
force-pushed
the
fix/include-nested-bracket-balance
branch
from
June 4, 2026 11:22
277ac35 to
fa2cff2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[[span]]...[[/span]]のような nested[[...]]や単独の]]が含まれると、従来の正規表現 (INCLUDE_PATTERN) が 最初の]]で directive を切ってしまい、値が途中で途切れ、残りが外側の wikitext に漏れ出していた問題を修正。[[[link]]]) が directive close]]と同一行で隣接する形 (...|cap=[[[link]]]]]) で link の]]]と close の]]のブラケットが重なり再構成できなかった既知のエッジも同時に解消。Changes
1.
]]での途切れを解消 (59fb1c4)packages/parser/src/parser/rules/block/module/include/resolve.ts:INCLUDE_PATTERN(regex) を廃止しscanIncludeDirectives(bracket-balanced スキャナ) に置換。[[でdepth+1、]]でdepth-1しdepth <= 0の]]で close。]]のみ。継続行の mid-line]](bare / nested) では閉じないため caption 等が途切れない。[[include x]] text) は opener 行で閉じ、後続の別 include を巻き込まない。expandIterative/expandIterativeAsyncをスキャナベースに書き換え。]]/ single-line / inline-trailing + 後続 include / triple-link(分離行) / 未バランス opener。2. triple-bracket link が close で途切れる問題を解消 (
277ac35)scanIncludeDirectivesで[[[ ... ]]]を block の[[/]]とは別の link depth で数える方式に変更。[[/]]を literal 扱いし block depth を動かさない。link の]]]が directive close]]と同一行で隣接 (...|cap=[[[link]]]]]) しても link が途切れず再構成される。Test plan
[[span class="ruby"]]黄山[[span class="rt"]]きやま[[/span]][[/span]]のようなネストした[[...]]を含む include で、すべての要素が値として保持される。]](例caption=記号 ]] を含む説明) で directive が早期終了しない。[[include tmpl |cap=[[span]]hi[[/span]]]]) で末尾の]]で close。[[include tmpl |cap=A]] trailing) で opener 行 close、trailingは別要素。caption=[[[link]]]を含む multi-line include で link が完全に保持される。|cap=[[[link]]]]]) でも link 完全保持。[[/]]が外側 directive close 判定に干渉しない。