docling icon indicating copy to clipboard operation
docling copied to clipboard

Heading not present in md output even with Furniture included

Open LalitAgarwalla opened this issue 5 months ago • 6 comments

Here is the PDF document - https://wp.iap2750.org/wp-content/uploads/2022/01/CBA-DRAFT-REV-3-eff-1_1_22.pdf

I have enabled ContentLayer.FURNITURE in the markdown output. Still the below heading is missing.

Image

LalitAgarwalla avatar Jun 25 '26 16:06 LalitAgarwalla

This is the same root cause as your other issue (#3693) [1]. The layout model classifies regions by position on a single page, so a non-repeating heading sitting at the top of a page gets tagged as PAGE_HEADER, which is then mapped to ContentLayer.FURNITURE. Even when you include ContentLayer.FURNITURE in the export, you'll get the heading back — but you'll also get every genuine repeating header/footer on every page, so it's a blunt workaround rather than a real fix.

The underlying gap is that Docling equates "looks like a header by position" with "is repeating furniture," without a cross-page check to see if the element actually repeats. @DanielNg0729 has proposed a reclassification pass in #3693 that would fix this class of issue — non-repeating top-of-page elements would be reclassified back into BODY (as SECTION_HEADER) instead of being treated as furniture.

In the meantime, the only workaround is the one you're already using (ContentLayer.FURNITURE included), combined with post-processing to filter out the genuinely repeating headers/footers yourself.

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about docling with Dosu Add Dosu to your team

dosubot[bot] avatar Jun 25 '26 16:06 dosubot[bot]

This is different from #3693 as adding ContentLayer.FURNITURE also does not generate in md output.

LalitAgarwalla avatar Jun 25 '26 16:06 LalitAgarwalla

Hi @LalitAgarwalla, I had a look, and I also think it's a different issue from #3693.

In #3693 the heading is just mislabeled as furniture, so adding ContentLayer.FURNITURE brings it back. Here it's missing from every layer because the whole "ARTICLE … / number-in-a-black-box" block is being detected as a single picture, and text inside a picture isn't written to the markdown so it gets dropped entirely. The text itself extracts fine, so nothing's wrong upstream.

I reproduced it on page 2: the header region comes back as one PICTURE cluster containing the ARTICLE + title cells, and none of that text makes it into the output.

Proposed approach:

  1. Confirm by dumping the page's layout clusters and checking which cluster the header cells land in (expecting a PICTURE over the number box absorbing the ARTICLE/title text), vs. a confidence-threshold drop or an overlap removal.
  2. Minimal fix (pending confirmation): don't silently drop backend-extracted text that falls inside a PICTURE region, keep the real text clusters as text instead of absorbing them into the picture. This preserves the heading without affecting genuine figure handling.
  3. Add a focused test using a small synthetic PDF (a text heading overlapping a filled rectangle) so the regression is covered without the 263-page fixture.

This is independent of the #3693 reclassification PR; I can open a separate PR. If it helps, I can confirm the exact drop point and share the cluster dump. Also, if you have some sample pdf that will also help a lot. Thank you very much!

DanielNg0729 avatar Jun 26 '26 02:06 DanielNg0729

Building on @DanielNg0729's spot-on root-cause (text cells get adopted as children of a low-confidence PICTURE cluster, then postprocess() strips them from the regular set, and the picture serializes as <!-- image --> without ever emitting its child text) — there's a downstream reason this class of drop is far worse than "a missing heading," and it's worth naming explicitly so it doesn't get filed as cosmetic.

Cross-reference targets, not just anchors. In regulated corpora (the user's sample is a CBA — Republic Airways pilot collective bargaining agreement), the vanishing ARTICLE … heading isn't a decorative title. It's the target of self-references like "as provided in Article 25" / "except as set forth in Section X." When the target heading is dropped at the cluster-remodeling boundary, every downstream string-search reference parser — the kind most "extract the cited section" pipelines run — silently resolves to nothing. There's no error, no "section not found"; the reference graph just breaks and the consumer can't tell whether the clause it got back (from adjacent surviving text) is the cited one or an unrelated fragment that happens to sit nearby. The blast radius of "heading gone" is the whole citation web that hangs off it.

Same asymmetry class, new mechanism. What makes this distinct from #3693 (mislabeled as furniture, recoverable via FURNITURE) is that here the text is gone from every export layer — which is exactly the signature of #3473 (OCR'd TextItems exist in the JSON texts[] with valid prov.bbox but 0 references from body.children, so md_content is empty). In both cases the content survives upstream (text extraction works, prov is intact) and is silently dropped at a boundary the export layer never surfaces. The picture-adoption path is a third mechanism for the same failure shape: content present upstream, gone downstream, no signal, two readers (JSON vs markdown) see different documents. That's the unifying thing to harden against, not each individual route.

The fix in #3708 is the right call, and a cheap generalization would close the class. Recovering heading text from misclassified PICTURE regions closes this specific path. The general guard: when a cluster classified as a special type (PICTURE / FIGURE / anything in SPECIAL_TYPES) adopts regular children that carry recoverable text, emit a per-page signal like {special_region_children_with_text: n, recovered_or_dropped: "dropped"} (or, even cheaper, a markdown HTML comment on the <!-- image --> line: <!-- image: 3 text cells absorbed, not emitted -->). That turns a silent total loss into an informed one without changing export semantics — a pipeline operator on a contract corpus can then assert "no operative text absorbed by picture regions" instead of discovering a broken citation graph three steps downstream when someone can't find Article 25.

zeweihan avatar Jun 26 '26 10:06 zeweihan

Great catch distinguishing this from #3693 — the fact that enabling ContentLayer.FURNITURE still doesn't surface the heading means this is a different failure stage than furniture demotion. The heading is either being dropped at a later structural/export filter, or misclassified into a category the FURNITURE flag doesn't recover. That distinction matters for diagnostics.

Wanted to add a legal-domain angle, since the attached sample is a real CBA (Republic Airways pilots agreement) and this class of document is where the failure is most consequential:

The heading text isn't decoration — it carries the canonical numbering. In a CBA (and most regulated contracts), the section heading is the reference target. Every cross-reference in the document (except as provided in Section 25, as defined in Article 14) resolves against the numbering embedded in the heading, not against the clause body. So when a heading vanishes from the exported markdown:

  • the clause body may survive, but the downstream reader (human or RAG) can no longer map it back to "Section 25";
  • every internal cross-reference that pointed at it becomes dangling with no error — the reference string still parses, it just resolves to nothing;
  • and because the surrounding text reads normally, there's no signal that anything is missing.

The two-stage failure split is the useful framing here:

  1. Furniture-recoverable (first line of defense) — item demoted to FURNITURE, opt-in flag brings it back. That's #3693.
  2. Structural-stage removal (second line) — item survives into DoclingDocument but is filtered out during markdown serialization, and isn't covered by FURNITURE. That's this issue.

Stage 2 is the more dangerous one for regulated corpora, because it implies the pipeline believed it understood the document and then silently dropped part of it at serialization. The user has no first-line flag to flip.

One thing that would make this whole class of "missing in md" reports cheap to triage: a structural-drops manifest at export time — the set of items present in the parsed DoclingDocument but absent from the emitted markdown, each tagged with its source page/bbox and the filter reason (furniture_layer, export_filter, classification=None, …). Right now "heading is gone from md" forces the user to eyeball-diff against the rendered PDF; with a manifest it becomes a one-line inspection. The same manifest would also catch the silent-loss cases in #3685 (ghost tables) and #3698 (merged-cell misattribution), since those are the inverse failure — structure that survives but is remapped — and a per-item source provenance tag is exactly what disambiguates "gone" from "wrong".

Appreciate the maintainers looking at whether this is a distinct code path from #3693 — confirming that would tell us whether the fix belongs in the FURNITURE classification or in the markdown exporter's filter.

zeweihan avatar Jun 28 '26 02:06 zeweihan

Classification labels added: priority:low, pdf.

These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.

github-actions[bot] avatar Nov 16 '26 16:11 github-actions[bot]