[feat][formatter] Integrate LaTeX formatter for improved formula readability

- Add latex_formatter.py based on tex-fmt (https://github.com/WGUNDERWOOD/tex-fmt)
- Update to_katex.py to use the new formatter
- Enhance LaTeX formula output with better formatting and readability

This integration helps make generated LaTeX formulas more readable and
maintainable by applying consistent formatting rules.
This commit is contained in:
三洋三洋
2025-03-03 00:55:40 +08:00
parent 5cda58e8fc
commit 5673adecff
2 changed files with 705 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
import re
from .latex_formatter import format_latex
def change(input_str, old_inst, new_inst, old_surr_l, old_surr_r, new_surr_l, new_surr_r):
result = ""
@@ -185,4 +187,8 @@ def to_katex(formula: str) -> str:
# remove extra spaces (keeping only one)
res = re.sub(r' +', ' ', res)
return res.strip()
# format latex
res = res.strip()
res, logs = format_latex(res)
return res