Repository: google-research/arxiv-latex-cleaner

Issue:
[Unexpected Behavior] Comments Not Removed on Lines with "auto-ignore"
While fixing issue #91, I discovered that comments in lines containing the word `auto-ignore` are not being removed as expected. This behavior is not documented in either the README or the help message, which may lead to unexpected outcomes for users. 
I suppose there is a specific reason for this behavior as it is also being tested 🤔

## Example
### Input:
```latex
Foo auto-ignore Bar ... % Top Secret Comment
```
### Output:
```latex
Foo auto-ignore Bar ... % Top Secret Comment
```
### Expected Output:
```latex
Foo auto-ignore Bar ... %
```

Discussion:

Patch:
diff --git a/arxiv_latex_cleaner/arxiv_latex_cleaner.py b/arxiv_latex_cleaner/arxiv_latex_cleaner.py
index 2b83c54..296e698 100644
--- a/arxiv_latex_cleaner/arxiv_latex_cleaner.py
+++ b/arxiv_latex_cleaner/arxiv_latex_cleaner.py
@@ -212,8 +212,10 @@ def _remove_iffalse_block(text):
 
 def _remove_comments_inline(text):
   """Removes the comments from the string 'text' and ignores % inside \\url{}."""
-  if 'auto-ignore' in text:
-    return text
+  auto_ignore_pattern = r'(%\s*auto-ignore).*'
+  if regex.search(auto_ignore_pattern, text):
+    return regex.sub(auto_ignore_pattern, r'\1', text)
+
   if text.lstrip(' ').lstrip('\t').startswith('%'):
     return ''
 


Test patch:
diff --git a/arxiv_latex_cleaner/tests/arxiv_latex_cleaner_test.py b/arxiv_latex_cleaner/tests/arxiv_latex_cleaner_test.py
index 8540e75..34e9488 100644
--- a/arxiv_latex_cleaner/tests/arxiv_latex_cleaner_test.py
+++ b/arxiv_latex_cleaner/tests/arxiv_latex_cleaner_test.py
@@ -278,6 +278,16 @@ class UnitTests(parameterized.TestCase):
           'line_in': '%auto-ignore\n',
           'true_output': '%auto-ignore\n',
       },
+      {
+          'testcase_name': 'auto_ignore_middle',
+          'line_in': 'Foo % auto-ignore Comment\n',
+          'true_output': 'Foo % auto-ignore\n',
+      },
+      {
+          'testcase_name': 'auto_ignore_text_with_comment',
+          'line_in': 'Foo auto-ignore % Comment\n',
+          'true_output': 'Foo auto-ignore %\n',
+      },
       {
           'testcase_name': 'percent',
           'line_in': r'100\% accurate\n',