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, 62 passed; with the fix: 63 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.

Fixes #5044

An AsciiDoc listing block opens on four or more hyphens and a literal block
on four or more dots; the Asciidoctor documentation calls the length a
minimum delimiter. The backend compared against 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.

The same file already applies the four-or-more rule to comment blocks.


Signed-off-by: Eapp1e <163811520+Eapp1e@users.noreply.github.com>
@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

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

The PR fixes the AsciiDoc backend so that listing and literal block delimiters of five or more characters (e.g. -----, .....) open and close a verbatim block, matching Asciidoctor's rule that four characters is a minimum. Two module-level regexes replace the exact-string tests in _iter_blocks, and a focused test verifies the fix.

Topic labels added: bug, asciidoc.

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

4 related pull request(s) in the same code
PR State Signal Assessment
#5039 open changes the same code related: PR 5039 fixes caption parent placement for pictures, tables, and code blocks; it touches _add_picture_item and _add_literal_block, not the delimiter-matching logic changed here.
#5010 open changes the same code related: PR 5010 adds row-grouping by column count and cell-span parsing for tables; it does not touch the verbatim block delimiter logic changed here.
#5008 open changes the same code related: PR 5008 fixes _parse_picture so a leading named attribute is not read as alt text; it does not touch the verbatim block delimiter logic changed here.
#3891 open changes the same code related: PR 3891 fixes inline-group whitespace in _flush_text_data; it does not touch the verbatim block delimiter logic changed here.

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

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) 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