Repository navigation
fix(asciidoc): replace attribute references with their values - #5117
sarankumar1325 wants to merge 8 commits into
Conversation
Attribute references such as {product} stayed literal in titles,
paragraphs, list items, table cells and block titles. Attribute entries
now set document attributes in order (header attributes also apply to
the document title), :name!: and :!name: unset them instead of leaking
into the next paragraph, \{name} keeps a literal reference, and a
reference to an unset attribute stays as written, as in Asciidoctor.
Asciidoctor's predefined character attributes ({nbsp}, {sp}, {empty},
...) are supported too. Listing and literal blocks stay verbatim.
Resolves docling-project#5116
Signed-off-by: sarankumar1325 <[email protected]>
|
✅ DCO Check Passed Thanks @sarankumar1325, 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 AsciiDoc backend read attribute entries (set, redefine, unset). It replaces 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): blocker found
This review covers the full diff at e06f5dc30d. It read the code and did not run it.
The main risk is table corruption when table cells contain attribute references with pipe characters, such as {vbar}. The reviewer must verify that attribute substitution for tables runs on individual cell contents after splitting delimiters instead of on the full line.
A maintainer makes the merge decision. This review never approves the pull request.
| elif self._is_table_line(line): # within a table | ||
| in_table = True | ||
| table_data.append(self._parse_table_line(line)) | ||
| table_data.append(self._parse_table_line(text_line)) |
There was a problem hiding this comment.
blocker: Attribute substitution before table parsing splits {vbar} into extra cells
The parser substitutes attribute references on the whole line before _parse_table_line splits the line into cells. When a cell contains {vbar} (defined as | in _INTRINSIC_ATTRIBUTES) or an attribute that contains |, _substitute_attributes inserts an unescaped pipe character into the line. _parse_table_line then splits on that pipe character as a column delimiter. This splits one cell into multiple cells and corrupts the table structure.
Substitute attribute references on each cell text after _parse_table_line splits the row into cells.
…tting
A value containing "|", such as {vbar}, was inserted before the row was
split into cells, so it became a column delimiter. Rows are now split
first and each cell (and each continuation line) is substituted.
Signed-off-by: sarankumar1325 <[email protected]>
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the changes since e06f5dc30d at f942260546. It read the code and did not run it.
The earlier blocker (table corruption when an attribute value contains |) is fixed. The incremental diff splits table rows on the raw line before applying attribute substitution, and the new test covers both {vbar} and a multi-pipe attribute value. No new issues found.
Earlier findings
- fixed (blocker): Attribute substitution before table parsing splits
{vbar}into extra cells
A maintainer makes the merge decision. This review never approves the pull request.
| # references replaced before its text is used. | ||
| if self._apply_attribute_entry(stripped_line, attributes): | ||
| continue | ||
| text_line = self._substitute_attributes(line, attributes) |
There was a problem hiding this comment.
Use {asterisk}not bold{asterisk} here. comes out bold and {backtick}ls{backtick} turns into code, since the refs get replaced before inline parsing. Asciidoctor swaps attributes in after quotes, so these should stay literal. Maybe worth a test?
Asciidoctor replaces attribute references after inline formatting, so
{asterisk}not bold{asterisk} and {backtick}ls{backtick} are plain text.
The backend replaced references before parsing inline marks, which made
them bold and code. Marks in paragraph values are now held as stand-ins
until the paragraph is formatted. Marks around a reference still format
its value.
Signed-off-by: sarankumar1325 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Hi @sarankumar1325, thank you for this pull request. It has a merge conflict with git fetch upstream
git rebase upstream/main
# resolve the conflicts, then:
git push --force-with-leaseWe can continue with the review and CI after that. |
Resolve conflict in asciidoc_backend.py by keeping attribute-reference substitution and mark protection from this branch alongside hyperlink parsing, _join_lines, and bold captions from main. Signed-off-by: sarankumar1325 <[email protected]>
…ute-references Signed-off-by: sarankumar1325 <[email protected]> # Conflicts: # docling/backend/asciidoc_backend.py
asciidoc_backend.py went over the 1500-line limit of the max-lines check. Move the attribute entry and reference helpers into asciidoc_attributes.py. Signed-off-by: sarankumar1325 <[email protected]>
Signed-off-by: sarankumar1325 <[email protected]>
AsciiDoc attribute references such as
{product}stayed literal in the converted output, and attribute entries were only partly handled (:name!:/:!name:unset entries leaked into the next paragraph as text).This change makes the AsciiDoc backend:
:name!:or:!name:), substituting references in values;{name}references in titles, section headings, paragraphs, list items, table cells and block titles (.Caption);\{name}as a literal{name}, and leave references to unset attributes as written (Asciidoctor's defaultattribute-missing: skip);{nbsp},{sp},{empty},{plus}, ...);Attribute names are matched case-insensitively, as in Asciidoctor.
Issue resolved by this Pull Request:
Resolves #5116
Checklist:
Review evidence:
Before: the example from the issue converted to
# Widget Guide/Welcome to {product} {version}./:version!:/The version is {version} now.After:
# Widget Guide/Welcome to Widget 2.4./The version is unset now.uv run pytest tests/test_backend_asciidoc.py: 67 passed. 4 of the 5 new tests fail onmain; the listing test is there to make sure code blocks are not substituted.ruff format/ruff check(v0.17.2): clean.ty check docling/backend/asciidoc_backend.py(ty 0.0.33): same diagnostics as onmain, nothing new.scripts/check_max_lines.py --max-lines=1500on the touched files: passes.make test/make validate.I used AI help to write this change. I reviewed and tested it myself.