LaTex
Some checks failed
build_docker / essential (push) Successful in 1s
build_docker / build_easyocr_gpu (push) Has been cancelled
build_docker / build_easyocr (push) Has been cancelled
build_docker / build_doctr (push) Has been cancelled
build_docker / build_doctr_gpu (push) Has been cancelled
build_docker / build_raytune (push) Has been cancelled
build_docker / build_paddle_ocr_gpu (push) Has been cancelled
build_docker / build_paddle_ocr (push) Has been cancelled

This commit is contained in:
2026-02-04 21:10:42 +01:00
parent b91e31e173
commit c796e4cc7f
2 changed files with 20 additions and 21 deletions

View File

@@ -95,20 +95,19 @@ def convert_latex_formulas(text):
"""Convert LaTeX formulas to styled text for easy copy-paste into Word equation editor.
Word's equation editor accepts LaTeX directly, so we preserve the LaTeX code
in a visually distinct format that users can copy and paste.
that users can copy and paste into Insert → Equation.
"""
# Block formulas $$...$$ - center and style as equation placeholder
# Block formulas $$...$$ - centered
def convert_block(match):
latex = match.group(1).strip()
# Style as centered, monospace text that's easy to identify and copy
return f'<p class=MsoNormal style="text-align:center;background:#f5f5f5;padding:8pt;margin:6pt 40pt;font-family:Consolas;font-size:10pt"><span lang=ES>{latex}</span></p>'
return f'<p class=MsoNormal style="text-align:center"><span lang=ES style="font-family:Cambria Math">{latex}</span></p>'
text = re.sub(r'\$\$([^$]+)\$\$', convert_block, text)
# Inline formulas $...$ - style as inline code
# Inline formulas $...$ - inline with math font
def convert_inline(match):
latex = match.group(1).strip()
return f'<span style="font-family:Consolas;font-size:10pt;background:#f5f5f5;padding:1pt 3pt">{latex}</span>'
return f'<span style="font-family:Cambria Math">{latex}</span>'
text = re.sub(r'\$([^$]+)\$', convert_inline, text)
return text