Skip to content

fix: preserve VLM section heading depth in exports - #4906

Closed
PierreMesure wants to merge 1 commit into
docling-project:mainfrom
PierreMesure:fix/vlm-heading-depth
Closed

PierreMesure wants to merge 1 commit into
docling-project:mainfrom
PierreMesure:fix/vlm-heading-depth

Conversation

@PierreMesure

Copy link
Copy Markdown
Contributor

Chandra <h3> and Nemotron ### section headings exported as ####. Convert source depths to Docling's title-relative section levels so exports keep their original depth and coordinates.

The HTML change is in the shared Chandra mapper, including _add_html_fragment callers. The related LightOnOCR PR #4789 now uses this correction and removes its compensating pass; the shared mapper change is identical in both branches.

Resolves #4902.

Checklist:

  • Documentation assessed: output correction; no API change.
  • Examples are included in regression tests.
  • Tests added for native envelopes, shared HTML fragments, formatted headings, and provenance.

Review evidence:

  • All 10 new regression cases failed before the fix.
  • .venv/bin/python -m pytest -q tests/test_vlm_heading_exports.py tests/test_chandra_vlm.py tests/test_nemotron_parse_v2.py tests/test_dots_parser.py: 93 passed on Python 3.12.
  • UV_NO_SYNC=1 make validate: all applicable hooks passed.
  • Existing assertions that stored HTML/Markdown depth directly now check the correct section level. No reference fixtures were regenerated.
  • Full Linux CI and model inference were not run locally.

Correct the shared HTML mapper and Nemotron native heading conversion. Add export and provenance regressions. Fixes docling-project#4902.

Signed-off-by: Pierre Mesure <pierre@mesu.re>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Oct 19, 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) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working vlm-pipeline labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

The PR corrects VLM section heading depth: both chandra_utils.py and nemotron_parse_utils.py now subtract 1 from the raw HTML/Markdown heading level so that Docling's title-relative level system exports the correct depth. A new parametrized test file verifies the fix across both parsers.

Topic labels added: bug, vlm-pipeline.

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

Possible duplicates

PR State Signal Assessment
#4789 open referenced as #4789; changes the same code duplicate: PR #4789 makes an identical change to chandra_utils.py and test_chandra_vlm.py — same lines removed and added, same comment — so only one of these two PRs can be merged.
2 related pull request(s) in the same code
PR State Signal Assessment
#4907 open changes the same code related: PR #4907 modifies nemotron_parse_utils.py and test_nemotron_parse_v2.py but fixes a different problem (stripping math delimiters from formula text), not the heading-level offset.
#4908 open changes the same code related: PR #4908 modifies the same Section-header block in nemotron_parse_utils.py but adds inline-math preservation, not a heading-level correction — a different fix in the same area.

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

@PierreMesure

Copy link
Copy Markdown
Contributor Author

The AI code review did not produce a verdict for head 155d5ff. The review job hit the 40-turn limit and returned no valid JSON. The publishing job then could not find ai-review-result. Both jobs show success because these steps allow errors.

The triage duplicate warning needs context: the shared Chandra correction also appears in #4789 by design. This PR also fixes Nemotron headings and adds focused export tests. Both PRs can merge after reconciling the identical shared change; they are not mutually exclusive. The four focused parser fixes were tested together again after the #4908 review fix: 129 passed, 1 skipped.

@dolfim-ibm
dolfim-ibm requested a review from cau-git October 21, 2026 04:28
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@PierreMesure

Copy link
Copy Markdown
Contributor Author

Closing as superseded by merged PR #4964, which includes the original signed-off commit and the heading-depth correction. The fix is now on main, and issue #4902 is closed. The remaining inline-math and LightOnOCR work continues in #4908 and #4789.

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:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working vlm-pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chandra and Nemotron section headings export one level too deep

1 participant