成功!

This commit is contained in:
qingxu fu
2023-06-03 00:34:23 +08:00
parent a643f8b0db
commit 5a1831db98
3 changed files with 77 additions and 25 deletions

View File

@ -42,13 +42,26 @@ class LinkTable():
self.preserve = preserve
self.next = None
def mod_inbraket(match):
# get the matched string
cmd = match.group(1)
str_to_modify = match.group(2)
# modify the matched string
str_to_modify = str_to_modify.replace('', ':')
str_to_modify = str_to_modify.replace('', ',')
# str_to_modify = 'BOOM'
# return the modified string as the replacement
return "\\" + cmd + "{" + str_to_modify + "}"
def fix_content(final_tex):
"""
fix common GPT errors to increase success rate
"""
final_tex = final_tex.replace('%', 'Percent')
final_tex = re.sub(r"\\([a-z]{2,10}) {", repl=r"\\$1{", string=final_tex)
final_tex = final_tex.replace('%', r'\%')
final_tex = final_tex.replace(r'\%', r'\\%')
final_tex = re.sub(r"\\([a-z]{2,10})\ \{", r"\\\1{", string=final_tex)
final_tex = re.sub(r"\\([a-z]{2,10})\{([^\}]*?)\}", mod_inbraket, string=final_tex)
return final_tex
class LatexPaperSplit():