Skip to content

feat: convert md→docx 支援 LaTeX math → 原生 OMath(downstream: bestOCR ocr-to) #141

Description

@kiki830621

Problem

macdoc convert --to docx file.md 對 markdown 內的 LaTeX math($...$ / $$...$$)是純文字直通——docx 內公式以字面 LaTeX 呈現(實測 v0.5.0:\beta 進 document.xml 為文字 run,無 <m:oMath> 元素)。

Expected

md→docx 路徑支援 $...$ / $$...$$ → Word 原生 OMath 轉換(可為 opt-in flag,如 --math omath)。

Context

參考

  • 轉換目標為 OMML(<m:oMath>);pandoc 的 texmath 是既有實作參考。

Current Status

Phase: closed
Last updated: 2026-09-01 by idd-close
Dashboard: For Reviewer / Collaborator

Key Decisions

  • Markdown → DOCX 維持向後相容的 literal 預設;原生 Word math 只由 --math omath 選擇性啟用。
  • v1 使用原始 CommonMark AST/source ranges 與保守 dollar delimiter scanner;unsupported/malformed formula 以具 UTF-8 source location 的公開錯誤 fail-loud。
  • inline/display 分別輸出有效的 m:oMathm:oMathPara carrier;所有 token 必須恰有一個允許的 consumer。
  • 全部公式掃描與解析在任何目的檔寫入前完成;失敗不建立或取代目的檔。

Scope Changes

  • source eligibility 覆蓋 code、HTML、autolink、link/reference/image destination、reference metadata、formatting boundary 與 CommonMark block/container。
  • multiline link/image fallback 以 enclosing paragraph、單調 cursor 與 KMP 維持 bounded-linear。
  • 同行與跨行 display closing 必須是原始 AST 明確認定的可見 Text;reference continuation Target="$$" 維持 byte-exact。
  • 乾淨套件基線的 42 個既有失敗由 bug: restore a green md-to-word-swift package test baseline #155 追蹤,不在本分支擴張處理。

Blocking

  • 無。Final verify:0 blocking、0 follow-up。
  • 模型多樣性限制:本環境無 Claude-family reviewer;已使用 5 個獨立 Codex agent lens 與 Codex CLI gpt-5.4 初審/delta 複審並揭露此限制。

Commits

  • 5119c36 — visible OMath closing、reference metadata、same-line opaque boundary 與 multiline recovery 線性化。
  • c42f343 — CommonMark UTF-8 source column 對齊與 library/compiled CLI regression。
  • Verified snapshot:idd-141-verified

Verification

Pull Request

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions