feat(parser)!: パーサーに診断(diagnostics)機能を追加#23
Merged
Conversation
parse()の診断基盤となる型定義を@wdprlib/astに追加。 Diagnostic(severity/code/message/position)とParseResult(ast + diagnostics)を定義。
BREAKING CHANGE: parse()がSyntaxTreeではなくParseResult { ast, diagnostics }を返すように変更。
ParseContextにdiagnostics配列を追加。
テストファイルにparseAst()ヘルパーを追加し、parse().astでSyntaxTreeを取得するように変更。 wdmock-cfのpipeline.tsでもparse().astを使用し、resolveModulesのコールバックをラップ。
div, collapsible, tabview/tab, align, iftagsの各ブロックルールに 閉じタグ不足のwarning診断を追加。 consumeFailedDivにインラインブロック要素のerror診断を追加。 メッセージは英語で統一し、codeフィールドでi18n対応可能。
tabviewルールのEOFハンドリングバグも修正
orphan-li、リスト内li閉じ忘れ、左寄せalignのunclosedテストを追加
expected-diagnostics.jsonがあるfail fixtureのdiagnosticsを検証する仕組みを追加
Wikidotのdivブロックは外側から内側へペアリングされる。 opens > closesの場合、最も内側の余剰openはテキスト化される。 - ParseContextにdivClosesBudgetフィールドを追加 - budget=0でdivルールがfail→テキストにフォールバック - countDivCloses()で残りclose数を計算 - consumeFailedDivのスキャンを改善: valid divブロック開始時に停止 - 吸収範囲内の追加[[div]]パターンにinline-block-element diagnostic発行
Wikidotではdivブロックに直接隣接するparagraphの<p>ラッピングが 抑制される。間に他のブロック要素がある場合は<p>を維持する。 - suppressDivAdjacentParagraphs()をpostprocessモジュールに追加 - トップレベルでのみ適用(div内部のparagraphは維持) - div後に続くunwrapped contentにはline-breakを先頭に付与
- expected.json: budget systemと<p>抑制を反映したAST - expected-diagnostics.json: case 1/2両方のinline-block-element - diagnostics.test.ts: budget systemの動作に合わせてテストを修正 - 余剰openはunclosed-blockではなくテキスト化される
blockCommentがsuccess:falseを返すとparagraph fallback経由で inlineCommentが同じdiagnosticを発行していた。 block側のdiagnostic pushを除去し、inline側に一元化。
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wdpr-demo-v1-files | e5f0dcd | Commit Preview URL Branch Preview URL |
Feb 12 2026, 01:59 PM |
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
parse()の戻り値をSyntaxTreeからParseResult { ast, diagnostics }に変更し、構文エラーを検出・報告する診断基盤を導入。Diagnostic型とParseResult型を@wdprlib/astに追加unclosed-block)、インラインブロック要素(inline-block-element)、閉じ忘れコメント(unclosed-comment)の3種の診断コードを実装<p>抑制を post-processing で実装Breaking Changes
parse()の戻り値がSyntaxTree→ParseResultに変更parse(input)→parse(input).astで従来のSyntaxTreeを取得可能parse(input).diagnosticsで診断情報の配列を取得