Files, encoding, and Unicode
Use UTF-8 input, Korean/Japanese/accented text, and exact output extensions.
Compare input and output
Compare the actual HTML/MathML input in your browser with the generated DOCX exported to PDF by LibreOffice. Open the DOCX in Word to inspect editable equations.
Browser · HTML / MathML
Open HTML previewLibreOffice · PDF
Open PDFFor Markdown and LaTeX examples, the browser shows the generated HTML or MathML. Browser MathML support, Word styles, fonts and page layout can produce different results.
The PDF panel shows page images. Open the original PDF to zoom, search or select text, or download the DOCX to edit it.
Run
Extract the example bundle, install the example dependencies, and run this command from the folder containing examples/:
python -m examples.02_files_unicode
Complete source
"""02 files unicode example."""
from mathml2docx import MathmlToDocx
from .support import OUTPUT
source = OUTPUT / "unicode.html"
source.write_text(
"<h1>안녕하세요</h1><p>Índice — 日本語 — Ελληνικά</p>", encoding="utf-8"
)
output = MathmlToDocx().parse_html_file(
source, OUTPUT / "02_files_unicode.docx", encoding="utf-8"
)
print(output)