Skip to content

fix(jats): keep the section title next to its label in headings - #5244

Merged
PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
MaiAditya:fix/jats-heading-label-title
Nov 12, 2026
Merged

PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
MaiAditya:fix/jats-heading-label-title

Conversation

@MaiAditya

Copy link
Copy Markdown
Contributor

Section headings were built from the first node of xpath("title|label"). JATS puts <label> before <title>, so a labelled section got only its number (## 1.) and the title was lost. Now the heading joins the label and the title with a space (## 1. Introduction), in document order, and skips empty parts. A section with only a title or only a label gets the same heading as before.

The same title|label pattern was used in four places, and all four are changed: body <sec>/<ack> headings, ref-list headings, structured abstract sections and the abstract label. The two body sites share a small helper, _get_heading_text. The abstract sites keep _get_node_text, as before.

One side effect: body heading text is now stripped, so a whitespace-only <title> no longer creates a heading " ".

Issue resolved by this Pull Request:
Resolves #5243

Checklist:

  • Documentation has been updated, if necessary. (not needed, no API change)
  • Examples have been added, if necessary. (not needed)
  • Tests have been added, if necessary.

Review evidence:

  • test_jats_section_heading_keeps_title_next_to_label and test_jats_abstract_section_heading_keeps_title_next_to_label in tests/test_backend_jats.py. They cover a label plus title, a nested section, title only, label only, and a label with an empty <title/>. On main they fail with ## 1. / ### 1..
  • Reference data: ptag100.xml is the only committed fixture with labelled sections. I regenerated it with DOCLING_GEN_TEST_DATA=1. Its 11 headings change from ## 1. to ## 1. Introduction, ### 2.1. to ### 2.1. Basic formulations: Hamiltonian and invariant, and so on. The .md, .json and .itxt files only change in those heading texts. No other groundtruth file changed.
  • uv run pytest tests/test_backend_jats.py -q: 109 passed
  • prek run --files <changed files>: all hooks passed or skipped (ruff, ruff format, ty, tach, max-lines, license header)
  • Not run: the full test suite (only the JATS tests were run).

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 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)(?:\(.+\))?(!)?:

🟢 Require two reviewer for test updates

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working xml issue related to supported schema-specific XML formats labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

This PR preserves both the label and title in JATS section headings. It joins the label and title text with a space in document order.

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

Reference data changes

Change Files
text 3
  • text tests/data/jats/groundtruth/ptag100.xml.itxt: +11 / -11 lines
  • text tests/data/jats/groundtruth/ptag100.xml.json: 11 text item(s) changed
  • text tests/data/jats/groundtruth/ptag100.xml.md: +14 / -14 lines

Assessment: expected. The updated reference files include the section title next to the section label in JATS headings.

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

@github-actions github-actions Bot 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.

AI first review (advisory): no blocker found

This review covers the full diff at 4087c06af3. It read the code and did not run it.

I found no defect. All four title|label sites now join label and title in document order, and empty parts are skipped. The body <sec>, <ack> and <ref-list> headings use _get_heading_text, and the abstract sites use _get_node_text as before. The body-heading test cases fail on the old header[0] code. In _walk_linear, an empty heading text still creates no heading and does not change self.hlevel.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 8, 2026
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

ceberam
ceberam previously approved these changes Nov 11, 2026

@ceberam ceberam 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.

Thanks @MaiAditya ! This is something that had to be fixed. The changes are minimal, precise, and well-tested. Thanks for your contribution 🚀

FYI: I rebase to main and force-pushed since there was a conflict with the test file

@ceberam
ceberam force-pushed the fix/jats-heading-label-title branch from 4087c06 to d03c456 Compare November 11, 2026 10:45
@github-actions github-actions Bot removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Nov 11, 2026
@github-actions github-actions Bot added the ai:ci-safe AI triage found no CI-safety concern (advisory) label Nov 11, 2026
@MaiAditya

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @ceberam! Mergify needs a second approval here because the PR updates test data. Could you suggest or ping someone who could take a look when they have time? Happy to make any changes they ask for.

@PeterStaar-IBM
PeterStaar-IBM merged commit b4cdb91 into docling-project:main Nov 12, 2026
34 checks passed
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) bug Something isn't working xml issue related to supported schema-specific XML formats

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JATS: section headings with a <label> lose their <title>

3 participants