Skip to content

fix(asciidoc): flush pending text at section headers - #4428

Merged
PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
simpleqt:sq/asciidoc-section-flush
Sep 28, 2026
Merged

PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
simpleqt:sq/asciidoc-section-flush

Conversation

@simpleqt

Copy link
Copy Markdown
Contributor

Summary

When a section header immediately follows body text (no blank line), the heading does not end the accumulated paragraph:

= Doc
== S1
=== S1.1
body
== S2
body2

→ a single paragraph body body2, parented under S2 — so "body" is attributed to the wrong section in the document tree.

Fix

The section-header branch now flushes text_data (via the existing _flush_text_data) into the current parent — the section the text was actually written under — before adding the heading. Blank-line-separated text was already flushed by the blank-line branch; this closes the no-blank-line case.

Regression test

Added test_heading_flushes_pending_paragraph in tests/test_backend_asciidoc.py:

  • red/green verified: fails against unpatched main (one merged paragraph under S2) and passes with the fix
  • asserts the exact parentage: body → S1.1, body2 → S2
  • full tests/test_backend_asciidoc.py suite passes: 19 passed

ruff check and ruff format pass on both touched files.

A heading ended the paragraph being accumulated only implicitly: the
text before the heading stayed in text_data, was joined with the text
after the heading, and was attributed to the latter's section. 'body'
under === S1.1 followed by == S2 and 'body2' came out as one paragraph
'body body2' parented under S2. Flush the pending text (into the
section it was written under) before adding the heading.

Red/green verified: the new test fails against the old implementation
(one merged paragraph under S2) and passes with the fix.

Signed-off-by: simpleqt <[email protected]>
Copilot AI lite review requested due to automatic review settings September 28, 2026 14:21

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Sep 28, 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!

@PeterStaar-IBM PeterStaar-IBM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@PeterStaar-IBM
PeterStaar-IBM merged commit e2f942e into docling-project:main Sep 28, 2026
26 checks passed
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.

3 participants