from fastcore.test import test_eq
helper.latex.comments
Deal with the comments of a LaTeX document
LaTeX comments
remove_comments
remove_comments (text:str)
= r"""% Commands with parameters
text \newcommand{\field}[1]{\mathbb{#1}}
\newcommand{\mat}[4]{\left[\begin{array}{cc}#1 & #2 \\
#3 & #4\end{array}\right]}
\newcommand{\dual}[1]{#1^{\vee}}
\newcommand{\compl}[1]{\hat{#1}}
"""
assert '%' not in remove_comments(text)
print(remove_comments(text))
= r"""Hi. I'm not commented. %But I am!"""
text "Hi. I'm not commented. ") test_eq(remove_comments(text),
\newcommand{\field}[1]{\mathbb{#1}}
\newcommand{\mat}[4]{\left[\begin{array}{cc}#1 & #2 \\
#3 & #4\end{array}\right]}
\newcommand{\dual}[1]{#1^{\vee}}
\newcommand{\compl}[1]{\hat{#1}}