don't escape backslashes

This commit is contained in:
Sina Atalay 2023-11-19 20:23:43 +01:00 committed by Jeffrey Goldberg
parent 9a01531229
commit b28193fe68
1 changed files with 6 additions and 5 deletions

View File

@ -69,12 +69,13 @@ def escape_latex_characters(sentence: str) -> str:
# Handle backslash and curly braces separately because the other characters are # Handle backslash and curly braces separately because the other characters are
# escaped with backslash and curly braces: # escaped with backslash and curly braces:
sentence = sentence.replace("{", ">>{") # --don't escape curly braces as they are used heavily in LaTeX--:
sentence = sentence.replace("}", ">>}") # sentence = sentence.replace("{", ">>{")
# don't escape backslash as it is used heavily in LaTeX: # sentence = sentence.replace("}", ">>}")
# --don't escape backslash as it is used heavily in LaTeX--:
# sentence = sentence.replace("\\", "\\textbackslash{}") # sentence = sentence.replace("\\", "\\textbackslash{}")
sentence = sentence.replace(">>{", "\\{") # sentence = sentence.replace(">>{", "\\{")
sentence = sentence.replace(">>}", "\\}") # sentence = sentence.replace(">>}", "\\}")
# Loop through the letters of the sentence and if you find an escape character, # Loop through the letters of the sentence and if you find an escape character,
# replace it with its LaTeX equivalent: # replace it with its LaTeX equivalent: