From 66cf5ca9120c7c057d22102ba89e0fda4e66e2e1 Mon Sep 17 00:00:00 2001 From: "matthias@quintern.xyz" Date: Sat, 26 Oct 2024 01:49:24 +0200 Subject: [PATCH] use mdtex2html for md conversion --- html-preprocessor | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/html-preprocessor b/html-preprocessor index b376783..9c2b8b3 100755 --- a/html-preprocessor +++ b/html-preprocessor @@ -393,11 +393,16 @@ def cmd_include(args: str, variables:dict[str, str]={}) -> str: content = f"" if filename.endswith(".md"): try: - from markdown import markdown - content = markdown(content, output_format="xhtml") + import mdtex2html as m2h # this package also converts tex to MathML + content = m2h.convert(content, extensions=["extra"]) except: - error("cmd_include", f"Could convert markdown to html for file '{filename}'. Is python-markdown installed?", level=error_levels["critical"], exit_code=exit_codes["MarkdownConversionError"]) - content = f"" + error("cmd_include", f"mdtex2html could not be imported, falling back to python-markdown for md to html conversion", level=error_levels["light"], exit_code=exit_codes["MarkdownConversionError"]) + try: + from markdown import markdown + content = markdown(content, output_format="xhtml", extensions=["extra"]) + except: + error("cmd_include", f"Could convert markdown to html for file '{filename}'. Is python-markdown installed?", level=error_levels["critical"], exit_code=exit_codes["MarkdownConversionError"]) + content = f"" glob_dependcies.append(filename) return content