MathML
All checks were successful
build_docker / essential (push) Successful in 0s
build_docker / build_paddle_ocr (push) Successful in 7m24s
build_docker / build_paddle_ocr_gpu (push) Successful in 27m31s
build_docker / build_easyocr (push) Successful in 23m46s
build_docker / build_easyocr_gpu (push) Successful in 26m37s
build_docker / build_doctr (push) Successful in 24m23s
build_docker / build_raytune (push) Successful in 5m46s
build_docker / build_doctr_gpu (push) Successful in 18m4s
All checks were successful
build_docker / essential (push) Successful in 0s
build_docker / build_paddle_ocr (push) Successful in 7m24s
build_docker / build_paddle_ocr_gpu (push) Successful in 27m31s
build_docker / build_easyocr (push) Successful in 23m46s
build_docker / build_easyocr_gpu (push) Successful in 26m37s
build_docker / build_doctr (push) Successful in 24m23s
build_docker / build_raytune (push) Successful in 5m46s
build_docker / build_doctr_gpu (push) Successful in 18m4s
This commit is contained in:
@@ -92,22 +92,25 @@ def md_to_html_para(text):
|
||||
|
||||
|
||||
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
|
||||
that users can copy and paste into Insert → Equation.
|
||||
"""
|
||||
# Block formulas $$...$$ - centered
|
||||
"""Convert LaTeX formulas to MathML for Word compatibility."""
|
||||
# Block formulas $$...$$
|
||||
def convert_block(match):
|
||||
latex = match.group(1).strip()
|
||||
return f'<p class=MsoNormal style="text-align:center"><span lang=ES style="font-family:Cambria Math">{latex}</span></p>'
|
||||
latex = match.group(1)
|
||||
try:
|
||||
mathml = latex_to_mathml(latex, display="block")
|
||||
return f'<p class=MsoNormal style="text-align:center">{mathml}</p>'
|
||||
except:
|
||||
return match.group(0) # Keep original if conversion fails
|
||||
|
||||
text = re.sub(r'\$\$([^$]+)\$\$', convert_block, text)
|
||||
|
||||
# Inline formulas $...$ - inline with math font
|
||||
# Inline formulas $...$
|
||||
def convert_inline(match):
|
||||
latex = match.group(1).strip()
|
||||
return f'<span style="font-family:Cambria Math">{latex}</span>'
|
||||
latex = match.group(1)
|
||||
try:
|
||||
return latex_to_mathml(latex, display="inline")
|
||||
except:
|
||||
return match.group(0)
|
||||
|
||||
text = re.sub(r'\$([^$]+)\$', convert_inline, text)
|
||||
return text
|
||||
|
||||
Reference in New Issue
Block a user