Skip to content

fix(asciidoc): open listing and literal blocks on four or more delimiters - #5045

Open
Eapp1e wants to merge 1 commit into
docling-project:mainfrom
Eapp1e:fix/asciidoc-minimum-delimiter
Open

Eapp1e wants to merge 1 commit into
docling-project:mainfrom
Eapp1e:fix/asciidoc-minimum-delimiter

Conversation

@Eapp1e

@Eapp1e Eapp1e commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An AsciiDoc listing or literal block opens on four or more delimiter characters — the Asciidoctor documentation names the length "minimum delimiter" and its is_delimited_block? accepts any uniform run. The backend tested only the exact strings ---- and ...., so a block with a longer marker was not opened: the markers stayed in the document as paragraphs and the code between them became prose.

$ python tmp/repro.py     # [source,python] / ----- / x = 1 / ----- / ..... / raw / .....
paragraph  text='----- x = 1 -----'
paragraph  text='....'  text='raw'  text='....'

Fix

Two regexes replace the exact-string tests:

-            if stripped in {"....", "----"}:
+            if _VERBATIM_DELIMITER_RE.fullmatch(stripped):
@@
-            if source_attr is not None and i + 1 < n and lines[i + 1].strip() == "----":
+            if (
+                source_attr is not None
+                and i + 1 < n
+                and _LISTING_DELIMITER_RE.fullmatch(lines[i + 1].strip())
+            ):
                 block_data = []
-                block_delimiter = "----"
+                block_delimiter = lines[i + 1].strip()

_VERBATIM_DELIMITER_RE is -{4,}|\.{4,}, and _LISTING_DELIMITER_RE is -{4,} because only a listing block takes a [source,lang] attribute. The closing check keeps comparing against the recorded opener, which matches Asciidoctor's behaviour of closing on an identical line. This mirrors the rule the same file already applies to comment blocks (_COMMENT_BLOCK_DELIMITER_RE = re.compile(r"/{4,}")).

Tests

tests/test_backend_asciidoc.py::test_delimiter_longer_than_four_characters_opens_the_block converts [source,python] + ----- + x = 1 + ----- and a ..... literal block, then asserts both become code items, that the language is Python, and that no marker text leaks into the body.

On the tree without the fix: 1 failed, 79 passed; with the fix: 80 passed.

$ python -m pytest -o addopts="" -p no:cacheprovider tests/test_backend_asciidoc.py -q

tests/test_backend_text_encoding.py (55 passed) and tests/test_input_doc.py (43 passed) are unchanged. No file under tests/data uses a delimiter longer than four characters, so no reference data changes.

The branch is now based on main at 9b25840, so the pull request no longer conflicts with the table-row change that landed in the same file.

Fixes #5044

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @Eapp1e, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) asciidoc issue related to asciidoc backend bug Something isn't working labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 19cb7a09f0. The analysis read the diff only. It did not run code from this pull request.

The AsciiDoc backend now opens a listing block on four or more hyphens and a literal block on four or more dots. A new test covers both cases.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#5039 open changes the same code related: This PR changes where captions attach for tables, pictures, and literal blocks. The PR under triage changes how a literal or listing block opens. The two changes touch the same area but fix different problems.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@Eapp1e
Eapp1e force-pushed the fix/asciidoc-minimum-delimiter branch from 3395211 to 5948305 Compare October 28, 2026 05:06
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:ci-safe AI triage found no CI-safety concern (advisory) labels Oct 28, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at 5948305ce1. It read the code and did not run it.

The fix correctly generalises listing and literal block delimiters from exact-string matches to 4-or-more-character regex matches. The test directly reproduces the reported defect. No regressions found in the closing logic (exact equality against the recorded opener is preserved) or in the ordering of delimiter checks.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Eapp1e

Eapp1e commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Friendly follow-up after a week: this one is a two-line widening of the listing/literal block delimiter check (four or more uniform delimiters), with a regression test for ----- and ...... DCO, merge protection and the AI triage comment above all pass, and there are no open review threads. Happy to adjust the wording of the docstring if that is what is holding it back.

AsciiDoc treats the delimiter length as a minimum: listing blocks open
with four or more hyphens and literal blocks with four or more dots.
The backend only accepted exactly four, so a block opened with five or
more delimiters was parsed as a paragraph and its content leaked into
running text.

Match four or more and keep the real delimiter line so the closing
delimiter is still found.

Signed-off-by: Eapp1e <[email protected]>
@Eapp1e
Eapp1e force-pushed the fix/asciidoc-minimum-delimiter branch from 5948305 to 19cb7a0 Compare November 5, 2026 15:11
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Nov 5, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at 19cb7a09f0. It read the code and did not run it.

I checked that regular expressions correctly recognize AsciiDoc listing and literal blocks with four or more delimiter characters without regressions in block closing or content leakage.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 5, 2026
@mergify mergify Bot mentioned this pull request Nov 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) asciidoc issue related to asciidoc backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(asciidoc): open listing and literal blocks on four or more delimiters

1 participant