Asciidoc 和数学方程式不会在 .docx 上呈现

Asciidoc and math equation does not render on .docx

我正在尝试将 .adoc 文件转换为 .docx

实际上我正在使用:

asciidoctor file.adoc -o file.html
pandoc -s -S file.html -o output.docx

我在 .adoc 中的数学方程式或符号等于:

latexmath:[$\phi$] and more text as Inline test latexmath:[$\sin(x)$]

它returns转换为docx后.docx里面的奇怪行:

\($\phi$\) and more text as Inline test \($\sin(x)$\)

有什么提示吗?

$ pandoc --version
pandoc 1.13.2.1
Compiled with texmath 0.8.2, highlighting-kate 0.5.15.

您需要使用 html 输入显式启用 tex_math_dollars 扩展:

pandoc -s -S file.html -f html+tex_math_dollars -o output.docx

并且 sed 可以处理剩余的转义括号 (\() :

asciidoctor file.adoc -o file.html
sed -r 's/\\(/\(/g' < file.html | sed -r 's/\\)/\)/g' > file2.html
pandoc -s -S file2.html -f html+tex_math_dollars -o output.docx