arxiv-to-prompt 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,13 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: arxiv-to-prompt
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: transform arXiv papers into a single latex prompt for LLMs
5
5
  Author: Takashi Ishida
6
- License: MIT License
7
-
8
- Copyright (c) 2025 Takashi Ishida
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
6
+ License: MIT
28
7
  Project-URL: Homepage, https://github.com/takashiishida/arxiv-to-prompt
29
8
  Project-URL: Changelog, https://github.com/takashiishida/arxiv-to-prompt/releases
30
9
  Project-URL: Issues, https://github.com/takashiishida/arxiv-to-prompt/issues
31
10
  Project-URL: CI, https://github.com/takashiishida/arxiv-to-prompt/actions
32
- Classifier: License :: OSI Approved :: MIT License
33
- Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3.8
35
- Classifier: Programming Language :: Python :: 3.9
36
- Classifier: Programming Language :: Python :: 3.10
37
- Classifier: Programming Language :: Python :: 3.11
38
- Classifier: Operating System :: OS Independent
39
11
  Requires-Python: >=3.8
40
12
  Description-Content-Type: text/markdown
41
13
  License-File: LICENSE
@@ -46,7 +18,7 @@ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
46
18
 
47
19
  # arxiv-to-prompt
48
20
 
49
- [![PyPI version](https://badge.fury.io/py/arxiv-to-prompt.svg)](https://pypi.org/project/arxiv-to-prompt/)
21
+ [![PyPI version](https://badge.fury.io/py/arxiv-to-prompt.svg?update=20250202)](https://pypi.org/project/arxiv-to-prompt/)
50
22
  [![Tests](https://github.com/takashiishida/arxiv-to-prompt/actions/workflows/tests.yml/badge.svg)](https://github.com/takashiishida/arxiv-to-prompt/actions)
51
23
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
24
  [![Changelog](https://img.shields.io/github/v/release/takashiishida/arxiv-to-prompt?label=changelog)](https://github.com/takashiishida/arxiv-to-prompt/releases)
@@ -71,6 +43,9 @@ arxiv-to-prompt 2303.08774 --no-comments
71
43
 
72
44
  # Copy to clipboard
73
45
  arxiv-to-prompt 2303.08774 | pbcopy
46
+
47
+ # Combine with the `llm` library from https://github.com/simonw/llm to chat about the paper
48
+ arxiv-to-prompt 1706.03762 | llm -s "explain this paper"
74
49
  ```
75
50
 
76
51
  The arXiv ID can be found in the paper's URL. For example, for `https://arxiv.org/abs/2303.08774`, the ID is `2303.08774`. It will automatically download the latest version of the paper, so you don't need to specify the version.
@@ -1,6 +1,6 @@
1
1
  # arxiv-to-prompt
2
2
 
3
- [![PyPI version](https://badge.fury.io/py/arxiv-to-prompt.svg)](https://pypi.org/project/arxiv-to-prompt/)
3
+ [![PyPI version](https://badge.fury.io/py/arxiv-to-prompt.svg?update=20250202)](https://pypi.org/project/arxiv-to-prompt/)
4
4
  [![Tests](https://github.com/takashiishida/arxiv-to-prompt/actions/workflows/tests.yml/badge.svg)](https://github.com/takashiishida/arxiv-to-prompt/actions)
5
5
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![Changelog](https://img.shields.io/github/v/release/takashiishida/arxiv-to-prompt?label=changelog)](https://github.com/takashiishida/arxiv-to-prompt/releases)
@@ -25,6 +25,9 @@ arxiv-to-prompt 2303.08774 --no-comments
25
25
 
26
26
  # Copy to clipboard
27
27
  arxiv-to-prompt 2303.08774 | pbcopy
28
+
29
+ # Combine with the `llm` library from https://github.com/simonw/llm to chat about the paper
30
+ arxiv-to-prompt 1706.03762 | llm -s "explain this paper"
28
31
  ```
29
32
 
30
33
  The arXiv ID can be found in the paper's URL. For example, for `https://arxiv.org/abs/2303.08774`, the ID is `2303.08774`. It will automatically download the latest version of the paper, so you don't need to specify the version.
@@ -46,4 +49,4 @@ latex_source = process_latex_source("2303.08774", keep_comments=False)
46
49
  ### References
47
50
 
48
51
  - Inspired by [files-to-prompt](https://github.com/simonw/files-to-prompt).
49
- - Reused some code from [paper2slides](https://github.com/takashiishida/paper2slides).
52
+ - Reused some code from [paper2slides](https://github.com/takashiishida/paper2slides).
@@ -1,23 +1,14 @@
1
1
  [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
2
+ requires = ["setuptools>=61.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "arxiv-to-prompt"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "transform arXiv papers into a single latex prompt for LLMs"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Takashi Ishida" }]
11
- classifiers = [
12
- "License :: OSI Approved :: MIT License",
13
- "Programming Language :: Python :: 3",
14
- "Programming Language :: Python :: 3.8",
15
- "Programming Language :: Python :: 3.9",
16
- "Programming Language :: Python :: 3.10",
17
- "Programming Language :: Python :: 3.11",
18
- "Operating System :: OS Independent",
19
- ]
20
- license = { file = "LICENSE" }
11
+ license = { text = "MIT" }
21
12
  requires-python = ">=3.8"
22
13
  dependencies = [
23
14
  "requests>=2.25.0",
@@ -151,8 +151,38 @@ def flatten_tex(directory: str, main_file: str) -> str:
151
151
  with open(file_path, 'r', encoding='utf-8') as f:
152
152
  content = f.read()
153
153
 
154
- # Process \input and \include commands
154
+ # Process \input and \include commands that are not commented out
155
155
  def replace_input(match):
156
+ # Check if the match is preceded by a comment character
157
+ line_start = content.rfind('\n', 0, match.start()) + 1
158
+ line_prefix = content[line_start:match.start()]
159
+
160
+ # If there's a % character in the line prefix that's not escaped,
161
+ # this command is commented out, so return the original text
162
+ comment_pos = -1
163
+ i = 0
164
+ while i < len(line_prefix):
165
+ if line_prefix[i] == '%':
166
+ # Check if the % is escaped with a backslash
167
+ if i > 0 and line_prefix[i-1] == '\\':
168
+ # Count backslashes before %
169
+ backslash_count = 0
170
+ j = i - 1
171
+ while j >= 0 and line_prefix[j] == '\\':
172
+ backslash_count += 1
173
+ j -= 1
174
+ # If odd number of backslashes, % is escaped
175
+ if backslash_count % 2 == 1:
176
+ i += 1
177
+ continue
178
+ comment_pos = i
179
+ break
180
+ i += 1
181
+
182
+ if comment_pos != -1:
183
+ return match.group(0) # Return the original text without processing
184
+
185
+ # Process the command normally
156
186
  input_file = match.group(1)
157
187
  if not input_file.endswith('.tex'):
158
188
  input_file += '.tex'
@@ -1,41 +1,13 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: arxiv-to-prompt
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: transform arXiv papers into a single latex prompt for LLMs
5
5
  Author: Takashi Ishida
6
- License: MIT License
7
-
8
- Copyright (c) 2025 Takashi Ishida
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
6
+ License: MIT
28
7
  Project-URL: Homepage, https://github.com/takashiishida/arxiv-to-prompt
29
8
  Project-URL: Changelog, https://github.com/takashiishida/arxiv-to-prompt/releases
30
9
  Project-URL: Issues, https://github.com/takashiishida/arxiv-to-prompt/issues
31
10
  Project-URL: CI, https://github.com/takashiishida/arxiv-to-prompt/actions
32
- Classifier: License :: OSI Approved :: MIT License
33
- Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3.8
35
- Classifier: Programming Language :: Python :: 3.9
36
- Classifier: Programming Language :: Python :: 3.10
37
- Classifier: Programming Language :: Python :: 3.11
38
- Classifier: Operating System :: OS Independent
39
11
  Requires-Python: >=3.8
40
12
  Description-Content-Type: text/markdown
41
13
  License-File: LICENSE
@@ -46,7 +18,7 @@ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
46
18
 
47
19
  # arxiv-to-prompt
48
20
 
49
- [![PyPI version](https://badge.fury.io/py/arxiv-to-prompt.svg)](https://pypi.org/project/arxiv-to-prompt/)
21
+ [![PyPI version](https://badge.fury.io/py/arxiv-to-prompt.svg?update=20250202)](https://pypi.org/project/arxiv-to-prompt/)
50
22
  [![Tests](https://github.com/takashiishida/arxiv-to-prompt/actions/workflows/tests.yml/badge.svg)](https://github.com/takashiishida/arxiv-to-prompt/actions)
51
23
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
24
  [![Changelog](https://img.shields.io/github/v/release/takashiishida/arxiv-to-prompt?label=changelog)](https://github.com/takashiishida/arxiv-to-prompt/releases)
@@ -71,6 +43,9 @@ arxiv-to-prompt 2303.08774 --no-comments
71
43
 
72
44
  # Copy to clipboard
73
45
  arxiv-to-prompt 2303.08774 | pbcopy
46
+
47
+ # Combine with the `llm` library from https://github.com/simonw/llm to chat about the paper
48
+ arxiv-to-prompt 1706.03762 | llm -s "explain this paper"
74
49
  ```
75
50
 
76
51
  The arXiv ID can be found in the paper's URL. For example, for `https://arxiv.org/abs/2303.08774`, the ID is `2303.08774`. It will automatically download the latest version of the paper, so you don't need to specify the version.
@@ -8,6 +8,7 @@ from arxiv_to_prompt.core import (
8
8
  find_main_tex,
9
9
  remove_comments_from_lines,
10
10
  check_source_available,
11
+ flatten_tex,
11
12
  )
12
13
 
13
14
  # Test fixtures
@@ -129,3 +130,49 @@ def test_find_main_tex(temp_cache_dir):
129
130
  found_main = find_main_tex(str(tex_dir))
130
131
  assert found_main == "main.tex"
131
132
 
133
+
134
+ def test_commented_input_commands(temp_cache_dir):
135
+ """Test that commented-out \\include and \\input commands are ignored."""
136
+ # Create test directory and files
137
+ tex_dir = temp_cache_dir / "test_commented_input"
138
+ tex_dir.mkdir(parents=True)
139
+
140
+ # Create a main file with both regular and commented-out input commands
141
+ main_file = tex_dir / "main.tex"
142
+ main_content = """\\documentclass{article}
143
+ \\begin{document}
144
+ % This is a comment with \\input{commented_file1}
145
+ Regular text
146
+ \\input{existing_file}
147
+ More text
148
+ % Another comment with \\include{commented_file2}
149
+ Text with escaped \\% and then % \\input{commented_file3}
150
+ % \\input{nonexistent_file}
151
+ \\end{document}
152
+ """
153
+ main_file.write_text(main_content)
154
+
155
+ # Create the file that should be included
156
+ existing_file = tex_dir / "existing_file.tex"
157
+ existing_content = "This is content from the existing file."
158
+ existing_file.write_text(existing_content)
159
+
160
+ # Run the flatten_tex function
161
+ result = flatten_tex(str(tex_dir), "main.tex")
162
+
163
+ # Check that the existing file was included
164
+ assert "This is content from the existing file." in result
165
+
166
+ # Check that the commented-out input commands are still present but not processed
167
+ assert "% This is a comment with \\input{commented_file1}" in result
168
+ assert "% Another comment with \\include{commented_file2}" in result
169
+ assert "Text with escaped \\% and then % \\input{commented_file3}" in result
170
+ assert "% \\input{nonexistent_file}" in result
171
+
172
+ # The commented files should not have been looked for
173
+ # (if they were, there would be error logs, but we can't easily test for that)
174
+ # So we'll check that the original text is preserved
175
+ assert "\\input{commented_file1}" in result
176
+ assert "\\include{commented_file2}" in result
177
+ assert "\\input{commented_file3}" in result
178
+ assert "\\input{nonexistent_file}" in result
File without changes