Skip to content

Commit

Permalink
Merge pull request #108 from arXiv/ARXIVCE-3242-command-end-of-file
Browse files Browse the repository at this point in the history
[ARXIVCE-3242] fix detection of commands at end of file
  • Loading branch information
norbusan authored Feb 24, 2025
2 parents 7489db6 + 4cd1905 commit 1be2ed3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello World
\include{bla}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass{article}
\begin{document}
\input foo
\end{document}
14 changes: 14 additions & 0 deletions tex2pdf-tools/tests/preflight/test_preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,17 @@ def test_multi_include_cmds(self):
self.assertEqual(sorted(tf.used_tex_files), ["a.sty", "b.sty", "c.tex", "e.tex"])
self.assertEqual(sorted(tf.used_other_files), ["aa.jpg", "bb.jpg", "cc.jpg", "dd.png", "ee.jpg"])
assert found_main

def test_no_final_newline(self):
"""Test whether detection of include command works with no final newline."""
dir_path = os.path.join(self.fixture_dir, "last-line-no-newline")
pf: PreflightResponse = generate_preflight_response(dir_path)
self.assertEqual(pf.status.key.value, "success")
self.assertEqual(len(pf.detected_toplevel_files), 1)
self.assertEqual(pf.detected_toplevel_files[0].filename, "main.tex")
found_foo_tex = False
for tf in pf.tex_files:
if tf.filename == "foo.tex":
found_foo_tex = True
self.assertEqual(tf.used_tex_files, ["bla.tex"])
self.assertTrue(found_foo_tex)
2 changes: 1 addition & 1 deletion tex2pdf-tools/tex2pdf_tools/preflight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def to_json(self, **kwargs: typing.Any) -> str:
\s*({[^}]*})?\s*(?:%.*\n)? # actual argument with braces
\s*({[^}]*})?\s*(?:%.*\n)? # second argument with braces
\s*({[^}]*})? # third argument with braces
(?=\s*\W) # any non-word character terminating the command
(?=\s*(\W|$)) # any non-word character terminating the command
"""

# All possible CompilerSpecs
Expand Down

0 comments on commit 1be2ed3

Please sign in to comment.