Search code examples
docxdocpandocasciidocasciidoctor

Asciidoc and math equation does not render on .docx


I'm trying to convert .adoc files to .docx

Actually I'm using:

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

My math equations or symbols inside .adoc are equal to:

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

It returns after conversion to docx the strange lines inside .docx:

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

Any hint?

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

Solution

  • You need to explicitly enable the tex_math_dollars extension with html input:

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

    And sed can deal with the remaining escaped parenthesis (\() :

    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