Repository navigation
fix(latex): convert text symbol macros such as \S and \ldots - #5192
Fahmid-Arman wants to merge 2 commits into
Conversation
Signed-off-by: Fahmid Arman <[email protected]>
|
✅ DCO Check Passed Thanks @Fahmid-Arman, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The PR makes the LaTeX backend convert text-symbol macros such as CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at f62a169641. It read the code and did not run it.
No blocking issue found. _char_macro_to_text runs before the other macro branches. It skips any name that the document redefines (self._custom_macros). Both the inline path (handlers/macros.py:428) and the text path (utils/text.py:317) call it. Headings, captions and \item terms get the new mapping too.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
adityasasidhar
left a comment
There was a problem hiding this comment.
@Fahmid-Arman hey could you run this on a larger latex corpus so that we can look out for edge cases. thank you 😃.
|
Sure. I ran this PR, #5188 and #5190 over 27 arXiv papers. I downloaded 30 sources, and 27 have a LaTeX main file. They include BERT, ResNet, Adam, GAN, VAE, GPT-3, ViT, U-Net, InstructGPT, LoRA, chain of thought, T5, LLaMA, Llama 2, DDPM, RoFormer, YOLOv3, XGBoost, the ATLAS Higgs paper, Shor's factoring paper and Perelman's Ricci flow paper. I converted each paper with the commit the three PRs branch from (
One thing the corpus shows that none of these PRs touch: a |
|
@Fahmid-Arman great! |
Signed-off-by: Fahmid Arman <[email protected]>
|
I merged |
|
I found a regression, when these symbols appear inside custom macro arguments: Expected:
Actual:
The symbols are converted before custom macro expansion finishes. The expansion is then parsed again, so the literal backslash starts a command and the literal dollar sign starts math. This introduces a regression: the base drops the symbols but preserves tmp and keeps the price as text. Two regression cases pass on the base and fail on this PR. Please preserve the LaTeX source during argument substitution and decode the symbols after expansion. These two cases should also be added to the tests. |
PeterStaar-IBM
left a comment
There was a problem hiding this comment.
can you please check this: #5192 (comment)
Issue resolved by this Pull Request:
Resolves #5191
_char_macro_to_textconverted accent and letter macros to Unicode, but any other macro without arguments fell through and its text was lost, so\S,\ldots,\textbackslash,\copyright,\LaTeXand similar symbols disappeared from paragraphs and headings. A newMACROS_TEXT_SYMBOLSmap inconstants.pygives the character for the common text-mode symbol macros, and_char_macro_to_textuses it after the accent and letter checks. The map is explicit becauselatex2textreturns an empty string for several of them (\S,\P,\copyright,\pounds,\euro,\LaTeX,\TeX).\textbulletstays out:\item[\textbullet]is read as the default list marker, whichtest_latex_item_term_without_textrelies on.Checklist:
Review evidence:
As shown in \S 3, the path C:\textbackslash tmp holds 1, 2, \ldots, n files.As shown in 3, the path C:tmp holds 1, 2, , n files.As shown in §3, the path C:\tmp holds 1, 2, …, n files.\copyright{} 2024 ACME. Typeset with \LaTeX.2024 ACME. Typeset with .© 2024 ACME. Typeset with LaTeX.test_latex_text_symbol_macrosintests/test_latex/test_macros.py, next totest_latex_accent_macro. It fails onmainand passes with the change.tests/data/latexgives the same documents as the groundtruth.jsonfiles.pytest tests/test_latex: all pass excepttest_e2e_latex_conversions, which fails onmainhere as well because this environment has no renderer for the LaTeX figures (predicted image is None); its Markdown, indented text, DocLang and LaTeX comparisons pass.ruff formatandruff check(v0.17.2) are clean on the changed files.