Releases: r74tech/wdpr
Releases · r74tech/wdpr
Release list
@wdprlib/render@3.0.0
@wdprlib/parser@4.1.0
@wdprlib/parser@4.0.0
@wdprlib/render@2.1.0
@wdprlib/parser@3.2.0
@wdprlib/parser@3.1.2
@wdprlib/ast@2.1.0
@wdprlib/parser@3.1.1
@wdprlib/runtime@1.0.3
@wdprlib/render@2.0.0
2.0.0 (2026-06-04)
🚀 Features
⚠️ ast, parser, render:WikitextSettings.allowHtmlBlocksを追加し[[html]]ブロックを context 別に無効化可能に (#46)
🩹 Fixes
- render: style属性内のurl()を安全なschemeで許可 (#40)
⚠️ Breaking Changes
- ast, parser, render:
WikitextSettings.allowHtmlBlocksを追加し[[html]]ブロックを context 別に無効化可能に (#46)
WikitextSettings に必須プロパティ allowHtmlBlocks が
追加された。手書きで WikitextSettings を構築している消費者は
allowHtmlBlocks フィールドの追加が必要。createSettings(mode) を経由
していれば影響なし。- feat(parser)!: allowHtmlBlocks=false で [[html]] を黙って消費
opener の]]を検証してから settings.allowHtmlBlocks === false を判定。
disabled 時はブロック全体を消費して空要素 (success:true / elements:[]) を
返し、ctx.htmlBlocks には push しない。close が見つからない場合も EOF まで
消費して同じく空要素を返す (unclosed-block warning + html-block-disabled
info の両方を emit)。中身が text として漏れない。
malformed opener (closing]]欠落) は従来どおり success:false で
fallback する。enabled 時の挙動は完全維持。
BREAKING CHANGE: WikitextSettings.allowHtmlBlocks が false の context
では [[html]] が AST にも html-blocks 配列にも出ない。 - feat(render)!: allowHtmlBlocks=false で html element を出力しない
renderHtmlBlock の先頭で ctx.settings.allowHtmlBlocks === false を判定し
早期 return。nextHtmlBlockIndex() の counter advance や htmlBlockUrl
resolver 呼び出しより前に置くことで、disabled-but-still-in-AST な
ブロック (手組み AST、キャッシュ AST、別 parser 由来) でも何も出力しない。
これによりパース側で settings ゲートが効かないパス (例: 手組み AST の
直接 render) でも enforcement boundary が保てる。
BREAKING CHANGE: WikitextSettings.allowHtmlBlocks が false の context
では html element をレンダしない (空)。 - test: allowHtmlBlocks の parser/render 両側のテスト追加
parser (tests/unit/parser/settings.test.ts):
- createSettings 既定値 (page=true / draft, forum-post, direct-message=false)
- enabled (page): [[html]] が html element になり html-blocks に push される
- disabled (draft): element 出ず html-blocks 空、html-block-disabled diagnostic、本文に漏れない
- disabled + unclosed: EOF まで consume、unclosed-block + html-block-disabled 両方 emit、漏れない
- disabled + 周囲非干渉: 前後の paragraph は残る
- forum-post / direct-message でも disabled になる
render (tests/unit/render/settings.test.ts): - enabled: iframe が出る
- disabled: 手組み AST に html element があっても iframe 出ない (enforcement boundary)
- disabled: htmlBlockUrl resolver が呼ばれない
- fix(parser): allowHtmlBlocks=false での leak と close-detection を強化
3 件の漏れ・誤検出を修正:
- (High) close-detection の修正
parseBlockName で名前が "html" と一致した時点で foundClose=true に
していたため、malformed[[/html no-close(BLOCK_CLOSE 欠落) で close
と誤認識し、後続テキストが leak する可能性があった。BLOCK_CLOSE まで
reach できることを確認してから close と認める実装に変更 (whitespace は
許容)。これにより disabled 時の unclosed パスも常に EOF まで consume
する。 - (Medium) text-level の [[html]] strip pre-pass を追加
block-rule の gate だけでは段落内before [[html]]X[[/html]] after
のような inline-position occurrence を捕まえられない (block dispatcher
が mid-paragraph トークンに到達しない)。Wikidot 互換の非貪欲 regex で
parse 開始時に text-level で strip し、両ポジションで漏れない設計に変更。
parse() にstripDisabledHtmlBlocksを追加。 - (Low) disabled 時の contents 累積をスキップ
disabled では body を破棄するため、token.value を contents に積む処理
をガード。大きな入力でのメモリ/CPU を節約。
test: 段落内 inline 漏れ防止 + malformed close 漏れ防止 のケースを追加。
- refactor(parser): allowHtmlBlocks gate を inline rule で実装 (text-level pre-pass 廃止)
text-level pre-pass の問題点を洗い直して再設計:
- (High) Parser class 直接使用で pre-pass がバイパスされる
- (High) closed のみ strip、mid-paragraph unclosed が漏れる
- (Medium) text-level pre-pass が [[code]]/[[html]] 等 raw 内も削除
- (Medium) strip 後の lex で diagnostic 位置がずれる
- (Medium) pre-pass の gate が truthiness、rule/render は === false
→ text-level pre-pass を廃止し、inline html rule 追加で再設計:
- packages/parser/src/parser/preprocess/strip-disabled-html.ts 削除
- parse() を元に戻す
- packages/parser/src/parser/rules/inline/html.ts (新規 htmlInlineRule):
- allowHtmlBlocks !== false: success:false (従来挙動維持)
- === false: [[html]]...[[/html]] を inline で消費、空要素返す
- close-detection は BLOCK_CLOSE まで verify (whitespace 許容)
- unclosed: NEWLINE+NEWLINE (blank line) で停止 (後続 paragraph 保護)
- block rule にも同じ blank-line 停止を追加
- inline rules 配列に登録 (commentRule の直後)
これで5件すべて解消:
- rule 自体が parse 時に走るので Parser 直接使用でも gate される
- inline rule が mid-paragraph closed/unclosed 両方扱う
- [[code]]/[[html]] 内は block rule で raw 扱いされ inline rule は到達しない
- source mutation なしで位置情報そのまま
- すべて === false に統一
test 追加: Parser 直接使用 / blank-line で stop / code 内 [[html]] 保護
- fix(parser): enabled html block の空行誤認 + close 末尾 whitespace 漏れを修正
2 件のバグを修正:
- (High) blank-line stop が enabled でも効き、空行を含む valid [[html]]
block が page mode で壊れる。例: [[html]]\none
\n\ntwo
\n[[/html]]
→ blank-line stop を disabled 時のみに限定。 - (Medium) close detection は [[/html ]] (whitespace before ]]) を
許容するが、close 消費側が whitespace を skip しておらず ]] が paragraph
text に漏れていた。close 消費側にも whitespace skip を追加。
test: 空行入り valid html block / whitespace 付き close tag のケース追加。
- fix(parser): disabled でも closed [[html]] の body 内空行で漏れていた問題を修正
disabled mode で blank-line stop が close より先に発火し、空行を含む
closed [[html]] (例: [[html]]\none
\n\ntwo
\n[[/html]]) の
後半two
と [[/html]] が paragraph text に漏れていた。
修正: 事前の forward lookahead で real close 存在を確認する
lookaheadHasHtmlClose ヘルパを追加し、close が ahead に存在する場合は
blank-line stop を抑止。close 不在 (truly unclosed) の時のみ blank-line
stop が効く。block rule / inline rule 両方に適用。
regression test: disabled mode で空行入り closed block が完全に消費される
ことを確認。
- feat(parser)!: allowHtmlBlocks=false で [[html]] を黙って消費
❤️ Thank You
- r74tech @r74tech