fix(parser): [[include]] 末尾の余分な ] を許容して terminator を見つける#48
Merged
Conversation
最後の引数値が `]` で終わる multi-line include (例: `[[include foo\n|key=val|bar=--]|]]` の改行省略形である `[[include foo\n|key=val|bar=--]]]`) で、scanIncludeDirectives が 「行末 blank ではない」と判定して terminator を見つけられず、 include 全体を生テキストとして残していた。 isRestOfLineBlank が行末判定で `]` も whitespace と同様に skip する よう修正。終端 `]]` で directive を close し、余分な `]` は include 外の raw text として残る。
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
decompiler-preview | 1c47366 | Commit Preview URL Branch Preview URL |
Jun 05 2026, 08:45 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wdpr-demo-v1 | 1c47366 | Commit Preview URL Branch Preview URL |
Jun 05 2026, 08:45 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wdpr-demo-v1-files | 1c47366 | Commit Preview URL Branch Preview URL |
Jun 05 2026, 08:45 AM |
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.
背景
最後の引数値が
]で終わる multi-line include — 例えば[[include foo\n|key=val|bar=--]|]]の改行省略形[[include foo\n|key=val|bar=--]]]— でscanIncludeDirectivesが terminator を見つけられず、include ディレクティブ全体が生テキストとして残ってしまっていた。原因は
isRestOfLineBlankの判定。]]で depth が 0 になった時点で「直後が空白+改行なら terminator」と判定するが、]]]のように直後に]が漏れ出ているケースでは「空白ではない」として close を拒否し、ループが closeEnd を見つけられないまま directive を諦めていた。変更点
isRestOfLineBlankの終端判定で]も whitespace と同様に skip する。これにより:[[include tmpl\n|cap= --]]]→<<-->>](]]で directive close、余分な]は include 外の raw text として残る)[[include tmpl\n|cap= --]]]\n\nafter→<<-->>]\n\nafter[[include tmpl\n|cap= x]]]]]→<<x>>]]]inline include (
[[include foo |arg=val]]) や、attribute 内に[[span]]...[[/span]]を含むケース、[[[link]]]を含むケースには影響なし。後方互換性
]]を見つけた瞬間に terminator として close する条件が緩和されるだけで、既存の close 条件 (opener-line または完全な行末 blank) でも従来通り close される。逆に既存の close 条件で raw text 化していたケースだけが新たに resolve されるようになるため、既存挙動への影響はない。Test plan
bun run lint(10 warnings, 0 errors — 既存箇所のみ)bun run formatbun run typecheckbun test(1295 pass / 0 fail)tests/unit/module/include/resolve.test.ts):]]の直後に stray]がある multi-line include]が複数連続する場合