mathpix预处理功能增加了将公式末的小括号移至公式外的功能

This commit is contained in:
weiye.wang 2023-07-16 23:07:39 +08:00
parent 006c4cf2f2
commit bbfda6e849
1 changed files with 1 additions and 0 deletions

View File

@ -982,6 +982,7 @@ def RefineMathpix(raw_string): # 进一步修改mathpix得到的字符串
string = re.sub(r"([\u4e00-\u9fa5\$])(?:\\bracket\{20\})*[\.]*[\s]*\n\\fourch",lambda matchobj: matchobj.group(1)+"\\bracket{20}.\n\\fourch",string) #给中文或公式结尾的题目最后一行加上选择题的括号.
string = re.sub(r"(%[^\n]*)\\blank\{50\}\.",lambda matchobj:matchobj.group(1),string) #注释行不加\blank{50}
string = re.sub(r"[\\\\]*\n(\(\d{1,2}\))(?:(?!\n)\s)*",lambda matchobj: "\\\\\n"+matchobj.group(1)+" ",string) #新一行的小题号回车前加上换行符
string = re.sub(r"\(([^\(\)]*(?:\\in |=|\\ge|\\le|>|<)[^\(\)]*)\)\$",lambda matchobj: "$($" + matchobj.group(1) + "$)",string) #公式最后的范围陈述的括号放到公式环境外
string = RefineChineseComma(string) #改顿号
return string