Skip to content

Commit

Permalink
Fix issue #93 (#96)
Browse files Browse the repository at this point in the history
* Fix issue #93

* Add tests

* Allow for white space and remove comments after `auto-ignore`

* Update test
  • Loading branch information
merajhashemi committed Mar 26, 2024
1 parent b7a0b3c commit 3859052
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arxiv_latex_cleaner/arxiv_latex_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''

Expand Down
10 changes: 10 additions & 0 deletions arxiv_latex_cleaner/tests/arxiv_latex_cleaner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,16 @@ def test_merge_args_into_config(self, args, config_params, final_args):
'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',
Expand Down

0 comments on commit 3859052

Please sign in to comment.