Skip to content

Commit

Permalink
Automatically remove incompatible package(s)
Browse files Browse the repository at this point in the history
Package axessibility is incompatible with xeCJK/xeLatex, causes compilation failure on the website. Removing it from tex file should fix that
  • Loading branch information
Zipper-1 committed Mar 3, 2024
1 parent c2b32a7 commit 5ac7995
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mathtranslate/process_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,12 @@ def replace_function(match):
else:
return match.group(0)
return pattern.sub(replace_function, latex)

def remove_incompatible_packages(text):
incompatible_list=['axessibility']
#axessibility is incompatible with xeCJK and can be removed savely
#maybe more will be added
for package in incompatible_list:
pattern = re.compile(r'\\usepackage(\[[A-Za-z]*?\])?\{'+package+r'\}')
text = re.sub(pattern,'',text)
return text
1 change: 1 addition & 0 deletions mathtranslate/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def translate_full_latex(self, latex_original, make_complete=True, nocache=False
if self.complete:
print('It is a full latex document')
latex_original, tex_begin, tex_end = process_latex.split_latex_document(latex_original, r'\begin{document}', r'\end{document}')
tex_begin = process_latex.remove_incompatible_packages(tex_begin)
tex_begin = process_latex.remove_blank_lines(tex_begin)
tex_begin = process_latex.insert_macro(tex_begin, '\\usepackage{xeCJK}\n\\usepackage{amsmath}')
else:
Expand Down

0 comments on commit 5ac7995

Please sign in to comment.