diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-11-04 10:55:26 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-11-04 10:55:26 +0000 |
| commit | 17fc54a672c575783d93d6b252823cf2bd39b4f5 (patch) | |
| tree | d7ed7a18ca54fafe5fa9ec0f91231a765230027d /docutils/utils | |
| parent | 1b79c258ead08d3473c325bb5f035d6f4e095970 (diff) | |
| download | docutils-17fc54a672c575783d93d6b252823cf2bd39b4f5.tar.gz | |
MathML: Small fixes for external latex -> MathML converters.
latexml: support amsfonts commands (``\mathbb`` etc.)
ttm: decode output
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk/docutils@9215 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/utils')
| -rw-r--r-- | docutils/utils/math/tex2mathml_extern.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/docutils/utils/math/tex2mathml_extern.py b/docutils/utils/math/tex2mathml_extern.py index eaeb421eb..adbc78793 100644 --- a/docutils/utils/math/tex2mathml_extern.py +++ b/docutils/utils/math/tex2mathml_extern.py @@ -19,7 +19,6 @@ the API is not settled and may change with any minor Docutils version. import subprocess document_template = r"""\documentclass{article} -\usepackage{amsmath} \begin{document} %s \end{document} @@ -33,7 +32,8 @@ def latexml(math_code, reporter=None): """ p = subprocess.Popen(['latexml', '-', # read from stdin - # '--preload=amsmath', + '--preload=amsfonts', + '--preload=amsmath', '--inputencoding=utf8', ], stdin=subprocess.PIPE, @@ -89,7 +89,7 @@ def ttm(math_code, reporter=None): close_fds=True) p.stdin.write((document_template % math_code).encode('utf-8')) p.stdin.close() - result = p.stdout.read() + result = p.stdout.read().decode('utf-8') err = p.stderr.read().decode('utf-8') if err.find('**** Unknown') >= 0: msg = '\n'.join(line for line in err.splitlines() @@ -146,7 +146,7 @@ def blahtexml(math_code, inline=True, reporter=None): if __name__ == "__main__": example = ('\\frac{\\partial \\sin^2(\\alpha)}{\\partial \\vec r}' - '\\varpi \\, \\text{Grüße}') - # print(latexml(example).encode('utf-8')) - # print(ttm(example)) - print(blahtexml(example).encode('utf-8')) + '\\varpi \\mathbb{R} \\, \\text{Grüße}') + # print(latexml('$'+example+'$')) + # print(ttm('$'+example.replace('\\mathbb{R}', '')+'$')) + print(blahtexml(example)) |
