feat: WikitextMode / WikitextSettings を導入#13
Merged
Conversation
- TOC コンテナ ID は固定値に戻す (runtime が #toc 等を参照するため) - TOC リンクの href を heading ID と同期させる (useTrueIds=false 時)
draft/forum-post/direct-message モードでは [[module CSS]] の <style> 出力をスキップし、ページレイアウトへの影響を防ぐ。
fall-through case + if による型チェックを個別 case に分割し、 TypeScript の型ナローイングを正しく活用するように修正
ID からの番号抽出ではなく、リンクテキスト(常に純粋な番号)を tooltip ラベルに使用するように変更
escapeHtml はダブルクォートをエスケープしないため、 属性値には escapeAttr を使用する (CodeQL 指摘対応)
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
ftml の WikitextMode / WikitextSettings パターンを wdpr に導入し、コンテキスト(ページ、ドラフト、フォーラム投稿、DM)に応じてパーサーとレンダラーの振る舞いを制御できるようにした。
astパッケージにWikitextMode/WikitextSettings型とcreateSettings()ファクトリ関数を追加enablePageSyntaxチェックを追加([[include]],[[module]],[[toc]]をモードに応じて無効化)allowLocalPaths(ローカルファイル画像のブロック)、useTrueIds(ID のランダム化)、allowStyleElements([[module CSS]]の出力制御)を追加Changes
新規ファイル
packages/ast/src/settings.ts— WikitextMode, WikitextSettings 型定義、createSettings(), DEFAULT_SETTINGStests/unit/parser/settings.test.ts— パーサー設定テスト(17件)tests/unit/render/settings.test.ts— レンダラー設定テスト(16件)+ allowStyleElements テスト(4件)変更ファイル
packages/parser— ParseContext / ParserOptions に settings を追加、include / module / toc に enablePageSyntax ゲート追加packages/render— RenderContext に settings / generateId / generateFixedId を追加、画像・TOC・footnote・bibliography・tab-view・math の ID 生成を対応、allowStyleElements チェック追加packages/runtime— footnote tooltip のラベル表示を ID 解析からリンクテキストに変更モード設定マトリクス
Test plan