Skip to content

feat: WikitextMode / WikitextSettings を導入#13

Merged
r74tech merged 14 commits intodevelopfrom
feature/wikitext-settings
Feb 7, 2026
Merged

feat: WikitextMode / WikitextSettings を導入#13
r74tech merged 14 commits intodevelopfrom
feature/wikitext-settings

Conversation

@r74tech
Copy link
Owner

@r74tech r74tech commented Feb 7, 2026

Summary

ftml の WikitextMode / WikitextSettings パターンを wdpr に導入し、コンテキスト(ページ、ドラフト、フォーラム投稿、DM)に応じてパーサーとレンダラーの振る舞いを制御できるようにした。

  • ast パッケージに WikitextMode / WikitextSettings 型と createSettings() ファクトリ関数を追加
  • パーサーに enablePageSyntax チェックを追加([[include]], [[module]], [[toc]] をモードに応じて無効化)
  • レンダラーに allowLocalPaths(ローカルファイル画像のブロック)、useTrueIds(ID のランダム化)、allowStyleElements[[module CSS]] の出力制御)を追加
  • runtime の footnote tooltip が randomized ID でも正しい番号を表示するよう修正

Changes

新規ファイル

  • packages/ast/src/settings.ts — WikitextMode, WikitextSettings 型定義、createSettings(), DEFAULT_SETTINGS
  • tests/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 解析からリンクテキストに変更

モード設定マトリクス

Mode enablePageSyntax allowLocalPaths useTrueIds allowStyleElements
page true true true true
draft true true false false
forum-post false false false false
direct-message false false false false

Test plan

  • 既存テスト全パス(973 pass, 0 fail)
  • 新規設定テスト全パス(37件)
  • lint / format / typecheck パス

- 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 指摘対応)
@r74tech r74tech merged commit 23582ae into develop Feb 7, 2026
6 checks passed
@r74tech r74tech deleted the feature/wikitext-settings branch February 7, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant