Repository navigation
fix(asciidoc): read superscript and subscript marks in paragraphs - #5787
Open
Aryapatel-007 wants to merge 1 commit into
Open
Aryapatel-007 wants to merge 1 commit into
Aryapatel-007 wants to merge 1 commit into
Conversation
^text^ and ~text~ stayed in the text as literal marks. They now set Formatting.script, as in the HTML, DOCX and ODT backends. As in Asciidoctor, the marks also work inside a word (H~2~O, E=mc^2^), but the marked text has no whitespace, so x^2 + y^2 stays plain. Math macros (stem:[...], latexmath:[...], asciimath:[...]) are kept as written, because their ^ and ~ belong to the formula. Resolves docling-project#5786 Signed-off-by: Arya Patel <aryapatel7899@gmail.com>
Contributor
|
✅ DCO Check Passed Thanks @Aryapatel-007, all your commits are properly signed off. 🎉 |
Contributor
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/
|
Contributor
AI triage (advisory)Checked commit Warning The AI analysis did not finish. Only the deterministic checks are shown. Topic labels added: CI safety: not assessed. Possibly related pull requests
The |
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.
The AsciiDoc backend kept superscript (
^2^) and subscript (~2~) marks in the text. This PR reads them asFormatting.script, like the HTML, DOCX and ODT backends do, and like #4824 did for bold, italic and monospace.The rule follows Asciidoctor:
H~2~O,E=mc^2^.x^2 + y^2and~/.bashrc and ~/xstay plain.**bold^sup^**and^*x*^.\^not^).Math macros (
stem:[...],latexmath:[...],asciimath:[...]) are now kept as written. Their^and~belong to the formula, and Asciidoctor formats nothing inside them. Without this, a corpus check (below) showedstem:[sum_(i=1)^n i^3=...]losing its carets. A side effect: bold and italic marks inside a math macro are also left alone now. Before,stem:[a *b* c]madebbold._parse_inlinenow has five parameters, so the flags aftertextare keyword-only.Issue resolved by this Pull Request:
Resolves #5786
Checklist:
Review evidence:
Water is H~2~O and E=mc^2^.2(sub),2(super)H~2~O and E=mc^2^H<sub>2</sub>O and E=mc<sup>2</sup>**bold^sup^**,^*x*^supbold and super,xbold and superx^2 + y^2,~/.bashrc and ~/xstem:[sum_(i=1)^n i^3=((n(n+1))/2)^2]test_superscript_and_subscript_in_paragraphs. It fails on main (a0bd0155) and passes with this change.pytest tests/test_backend_asciidoc.py: 95 passed. The AsciiDoc reference outputs did not change.pytest tests/test_backend_text_encoding.py tests/test_input_doc.py: 136 passed, 12 failed. The same 12 fail on main in my environment, all with "The 'docling-parse' package is required", because I did not install the PDF parser.ruff format --check,ruff check(0.17.2),tach check: clean.ty check(0.0.33) on the backend: no new warnings (4 on main, 4 here)..adocfiles from the Asciidoctor, Asciidoctor PDF, AsciidoctorJ, Asciidoctor Diagram, Gradle and Maven plugin repos and asciidoctor.org, on main and on this branch, and compared the text items, their formatting and the Markdown. One file changes:asciidoctor.org/news/docker-asciidoctorj-announcement.adoc, where the footnote markers^*^become a superscript*, as Asciidoctor renders them. No conversion fails.^apairs converts in about 2.6 s (it makes 100,000 items) and the regular expression alone takes 0.03 s. Unclosed marks scan in linear time too.Known output details, not from this change:
H2Oandmc2, the same as for<sub>and<sup>from the HTML backend.^*^now exports to Markdown as* For now, ..., which a Markdown reader takes as a list item. The serializer does not escape a leading*(docling-core#61).I used Claude Code to help with this change.