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: needs-fix
Last updated: 2026-08-14 by idd-verify R3
Dashboard: For Reviewer / Collaborator

Key Decisions

  • Markdown → DOCX 維持向後相容的 literal 預設;原生 Word math 只由 --math omath 選擇性啟用。
  • v1 使用保守 dollar delimiter scanner 與 latex-math-swift v0.2.0 子集,unsupported/malformed formula 以具來源位置的公開錯誤 fail-loud。
  • inline/display 分別輸出 m:oMathm:oMathPara,並在任何目的檔寫入前完成全部掃描與解析。

Scope Changes

Blocking

  • R3:multiline display span可跨原始CommonMark block/container,成功轉檔時改變文件結構。
  • R3:multiline reference label與angle destination grammar不完整,可把generated placeholder寫進relationship target。
  • R3:multiline/quoted HTML boundary未完整排除,可造成隱藏公式失敗或可見placeholder外洩。
  • R3:$*x*$等跨formatting-node delimiter與frozen proposal non-goal不一致。

Closed since R2

  • Marker allocation O(N²)已以一次預索引與Set lookup關閉。
  • 普通multiline inline link/image destination regression已綠,但完整destination grammar仍由R3阻擋。
  • transformed AST display validation已加入,但原始跨block span仍須在替換前拒絕。

Commits

  • d79e6a5 — native Markdown OMath conversion, CLI surface, specs, tests, and documentation.
  • 3365faf — archived namespace、已知 container/reference 邊界與 render-time token lookup remediation.
  • 68c7403 — multiline link、AST display validation與linear marker remediation.

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