Repository navigation
fix(arxiv): keep the character before an inline comment - #2534
Open
alphasafal wants to merge 1 commit into
Open
alphasafal wants to merge 1 commit into
alphasafal wants to merge 1 commit into
Conversation
The inline-comment pattern `[^\\]%.+$` consumed the character in front of `%`, so "setup% see appendix" became "setu", and it never matched a `%` at the end of a line, which stayed in the text. Use a lookbehind so only the comment is removed; escaped `\%` is still kept. Signed-off-by: Safal Gupta <[email protected]>
alphasafal
requested review from
a team and
abhinavg4
and
a balanced review from Copilot
and removed request for
a team
October 25, 2026 14:50
Contributor
[Medium impact] This PR appears safe to merge. SummaryFixes arXiv comment removal so text before an inline comment stays intact.
No actionable issues found. Tests were inspected but not run. Reviews (1) · Last reviewed commit: "fix(arxiv): keep the character before an..." · Reviewed by Greptile |
2 of 3 tasks
Author
|
@abhinavg4 could you or another vetter approve the CI run for this? copy-pr-bot is still waiting. It's a one-line regex fix with a regression test. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ArxivExtractor._clean_tex_fileremoves inline LaTeX comments with[^\\]%.+$. The[^\\]part is consumed by the match, so the character in front of every%comment is deleted along with it, and.+needs at least one character after%, so a%at the end of a line is never removed:We use the standard setup% see the appendixWe use the standard setuWe use the standard setupA line ending in a comment marker%A line ending in a comment marker%A line ending in a comment markerAccuracy is 95\% on the test set.The pattern is now
(?<!\\)%.*$: the lookbehind keeps escaped\%without consuming the preceding character, and.*also matches a bare trailing%. Every arXiv paper that uses inline comments is affected, which is common in LaTeX sources.This is in the same function as #2500 (the
\paragraphheader pattern) but on different lines, so the two do not conflict.Usage
Checklist
test_inline_comment_keeps_text_before_percentintests/stages/text/download/arxiv/test_extract.pyfails onmainand passes with this change; the rest of that file passes too. ruff 0.14.10 check and format are clean. The commit is signed and signed off.