Skip to content

feat: tex-to-docx converter — LaTeX 逐字稿轉 DOCX #56

@kiki830621

Description

@kiki830621

Problem

目前 make docxlatexpand → sed → pandoc 三步管線將 LaTeX 逐字稿轉為 DOCX,但:

  • pandoc 不認識自訂 LaTeX 命令(\摘要{}\篇名{}{}\kw{}\tc{}
  • sed 預處理只能做簡單替換,無法生成帶樣式的 DOCX(字型、顏色、框線)
  • 產出的 DOCX 格式粗糙,缺少摘要框、篇名樣式、關鍵詞顏色

Proposed Solution

新增 tex-to-docx-swift converter package,直接解析 LaTeX 源碼並用 OOXMLSwift 生成帶完整樣式的 DOCX。

需要處理的 LaTeX 命令

命令 PDF 效果 DOCX 對應
\篇名{行1}{行2} 思源宋體 Bold 24pt 置中,獨立頁 Heading 1 + 置中 + page break
\摘要{文字} 灰框白底 ◆ 前綴 14pt Quote style + border + ◆ prefix
\kw{關鍵詞} 深藍色文字 Bold + blue color
\tc{時間碼} 灰色括號 Gray colored run
\section{} 白字深色底條 Heading 2
\subsection{} 深棕色粗體 Heading 3
\subsubsection{} 深藍色 + 【】 Heading 4

Architecture

  • Package: packages/tex-to-docx-swift/
  • Converter: TeXToDOCXConverter conforming to DocumentConverter
  • CLI: macdoc tex to-docx input.tex -o output.docx
  • Dependencies: common-converter-swift, ooxml-swift
  • Uses latexpand (or built-in \input expansion) to flatten before parsing

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions