Skip to content

feat(decompiler): HTML→Wikidot逆変換パッケージを追加#25

Merged
r74tech merged 4 commits intodevelopfrom
feature/decompiler
Feb 17, 2026
Merged

feat(decompiler): HTML→Wikidot逆変換パッケージを追加#25
r74tech merged 4 commits intodevelopfrom
feature/decompiler

Conversation

@r74tech
Copy link
Owner

@r74tech r74tech commented Feb 14, 2026

Summary

  • @wdprlib/decompiler パッケージを新規作成
  • HTML → AST (htmlToAst) と AST → Wikidot構文 (serialize) の2段階変換
  • decompile(html) で一括変換
  • フォーラム投稿HTMLからWikidot構文を再生成するのが主な用途
  • roundtripテスト: 67フィクスチャ全パス
  • examples/decompiler-preview/ にデモアプリを追加(Vite SPA、2ペイン+タブ切替)

Supported elements

Inline: bold, italics, underline, strikethrough, superscript, subscript, monospace, color, links, images, math, footnotes, anchors, bibliography cites

Block: paragraphs, headings, blockquotes, alignment, divs, spans, lists, definition lists, tables, code blocks, collapsible blocks, tab views, math, embeds, iframes, horizontal rules, clear floats,
footnote blocks, bibliography blocks, CSS modules

Limitations

  • Best-effort conversion(再パースで構造的に等価なHTMLが生成されればOK)
  • コードブロックの言語検出(ハイライト済みHTML)は非対応
  • modules, includes, iftags, commentsはスコープ外

- パッケージスケルトン作成(package.json, tsconfig.json, bunup設定)
- HTML→AST変換: テキスト・段落・インライン書式・見出し・リンク・画像・
  リスト・テーブル・コード・collapsible・tabview・脚注・数式・
  div/span/blockquote・color・raw・embed・iframe等
- AST→Wikidot構文シリアライズ: 全要素の逆変換
- div_/span_ (paragraph-strip) の自動検出
- 空行管理(paragraph/block二段階システム)
- fixtureベースの統合テスト(serialize/decompile/roundtrip)
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 14, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wdpr-demo-v1 7fc253b Commit Preview URL

Branch Preview URL
Feb 17 2026, 02:53 AM

- decompiler-preview: HTML入力をサニタイズしてからinnerHTMLに代入
- fixture-roundtrip: HTMLエンティティの置換順序を修正し二重アンエスケープを防止
HTML→AST→FTMLのパスで、<div>内に<img>が<p>なしで存在する場合に
[[div_]]と誤判定される問題を修正。

- isParagraphStripの条件を「先頭が非block-level」から
  「先頭または末尾がテキスト系inline要素」に変更
- isInlineTextElement関数を追加し、text/line-break/link等の
  テキスト系要素のみdiv_をトリガーするようにした
- imageのような非テキスト系inline要素はdiv_をトリガーしない
@r74tech r74tech marked this pull request as ready for review February 17, 2026 03:02
@r74tech r74tech merged commit d664c00 into develop Feb 17, 2026
8 checks passed
@r74tech r74tech deleted the feature/decompiler branch February 17, 2026 03:02
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