Skip to content

fix(asciidoc): keep a titled paragraph and the text after it - #4391

Open
r0h1tb wants to merge 1 commit into
docling-project:mainfrom
r0h1tb:fix/asciidoc-block-title-paragraph
Open

r0h1tb wants to merge 1 commit into
docling-project:mainfrom
r0h1tb:fix/asciidoc-block-title-paragraph

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Problem

A block title in front of a paragraph drops the paragraph and all the text after it:

src = b"Intro paragraph.\n\n.Block title\nTitled paragraph.\n\nAfter paragraph.\n"
doc.export_to_markdown()  # 'Intro paragraph.'

After .Block title, the "allow multiline captions" branch appends every following non-empty line to caption_data. That buffer is only emitted when a table, picture, list or literal block comes next, so everything up to that point, or to the end of the document, is lost without an error. A block title with nothing after it is lost the same way.

Fix

A block title is a single line, so the line after it starts the paragraph it titles. The block title is now emitted as a bold paragraph just before it, which is what _parse's docstring already describes for targets without a caption slot, and what the list branch does. The pending title is also flushed at the end of the document. The list branch now uses the same helper; its behaviour is unchanged.

Tests

Two new tests in tests/test_backend_asciidoc.py: a titled paragraph followed by more text (exact labels, texts and order, bold title), and a block title at the end of the document. Both fail on main. The asciidoc module goes from 17 passed to 19, with the example groundtruth unchanged. ruff is clean and ty reports no new diagnostics beyond the file's existing _backend.convert() warnings.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

After a block title such as `.Procedure`, every following non-empty line
was collected into the caption buffer, which is only emitted when a
table, picture, list or literal block comes next. A titled paragraph and
all text after it up to such a block was dropped, and a block title at
the end of the document was lost too.

A block title is a single line, so emit it as the bold paragraph the
parser already uses for a target without a caption slot, and keep the
paragraph as a paragraph.

Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Sep 26, 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)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant