arxiv-latex-cleaner icon indicating copy to clipboard operation
arxiv-latex-cleaner copied to clipboard

Feature request: more universal and robust comments deletion?

Open refraction-ray opened this issue 5 years ago • 2 comments

This example is helpful considering various scenarios when deleting comments in tex files. And I show the example below:

\begin{document}
hello world
% comment after %
20\% just a percent 
new line \\%still a comment
\begin{comment}
comment even without percent % haha
\end{comment}
\begin{verbatim}
% not a comment though with %
\end{verbatim}
\end{document}
after document

In current version of this script:

  1. No support for verbatim package. Since every char within verbatim env is not comment even with %.

  2. Cannot delete comment directly attached after the newline \\, it will recognize \\% as \ \% where \% is just a percent symbol instead of the beginning of comment.

  3. Maybe it is also relevant to delete everything below \end{document} since they would never be involved with the file.

1, 3 are more like feature requests while I think it would be better to fix 2.

refraction-ray avatar Jun 16 '19 15:06 refraction-ray

Hi @refraction-ray Thanks for the example and for pointing out current limitations! I'll mark this issue as 'enhancement' for 1 and 3, bug for 2. In any case, I always recommend quickly checking the output code to see if some comment has been missed.

jponttuset avatar Jun 17 '19 10:06 jponttuset

You could have a look at #31, which introduces a general regex replacement pipeline. You could use this feature to build a multi-line regular expression for your comment string and replace it with an empty string ("").

pattern : '(:?\\begin{verbatim}\s*.*\s*\\end{verbatim})'
insertion: ''

Of course, don't nail me down on that regex pattern which I just improvised, but I think you get the gist.

theRealSuperMario avatar Sep 08 '20 19:09 theRealSuperMario