fix special latex character escaper

This commit is contained in:
Sina Atalay
2024-11-01 20:35:50 -04:00
parent d5fff8dace
commit 45cdab4024
2 changed files with 7 additions and 0 deletions

View File

@@ -336,6 +336,9 @@ def escape_latex_characters(latex_string: str) -> str:
# Dictionary of escape characters:
escape_characters = {
"{": "\\{",
"}": "\\}",
"\\": "\\textbackslash{}",
"#": "\\#",
"%": "\\%",
"&": "\\&",

View File

@@ -124,6 +124,10 @@ def test_markdown_file_class(tmp_path, rendercv_data_model, jinja2_environment):
"$$a=5_4^3 % & #$$ # $$aaaa ___ &&$$",
"$a=5_4^3 % & #$ \\# $aaaa ___ &&$",
),
(
"$\\mathcal{O}(n^2)$ to $\\mathcal{O}(n \\log n)$",
"\\$\\textbackslash{}mathcal\\{O\\}(n\\textasciicircum{}2)\\$ to \\$\\textbackslash{}mathcal\\{O\\}(n \\textbackslash{}log n)\\$",
),
],
)
def test_escape_latex_characters(string, expected_string):