Skip to content

fix(latex): keep the items of an \input file in the open list - #5413

Merged
PeterStaar-IBM merged 1 commit into
mainfrom
fix/latex-input-list-items
Nov 19, 2026
Merged

PeterStaar-IBM merged 1 commit into
mainfrom
fix/latex-input-list-items

Conversation

@cau-git

@cau-git cau-git commented Nov 16, 2026

Copy link
Copy Markdown
Member

Since #4518, the LaTeX list handler splits a list body into items before it reads an \input file. The \item lines of that file were then processed inside the previous item. They became plain text, and the later items got the wrong numbers.

This change reads each \input / \include file of a list body first and splices its nodes into the body, as LaTeX does with plain text inclusion. The file reading moves to _read_input(). It keeps the path-traversal, cycle and depth checks of the \input handler, and the splice uses the same cycle and depth guard.

Checklist:

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

Review evidence:

Source:

\begin{enumerate}
\item Paper A
\input{items}      % items.tex: \item Paper B, \item Paper C
\item Paper D
\end{enumerate}
  • Before (main): 2 list items. Markdown is 1. Paper A, then Paper B and Paper C as plain lines, then 2. Paper D.
  • After: 4 enumerated list items, 1. Paper A to 4. Paper D.
  • A list that holds only \input{items} still gives 2 items, as before.
  • Before fix(latex): number the items of enumerate lists #4518 the same source gave 4 list items, so this restores that structure.

Tests:

  • New tests/test_latex/test_lists.py::test_latex_list_items_from_input_file. The included file also inputs itself, so the test checks that the cycle is skipped. The test fails without the fix and passes with it.
  • pytest tests/test_latex: 219 passed, 1 skipped, 5 xfailed.
  • The pre-commit hooks (ruff, ty, tach, max-lines and the others) pass on the changed files.
  • No reference data changed.
  • Not run: the full test suite.

Since #4518 the list handler splits a list body into items before it
reads an \input file. The \item lines of the file were then processed
inside the previous item, so they became plain text and the later items
got the wrong numbers.

Read each \input file of a list body first and splice its nodes into the
body, as LaTeX does with plain text inclusion. The file reading moves to
_read_input(), which keeps the path, cycle and depth checks of the
\input handler.

Signed-off-by: Christoph Auer <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @cau-git, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Nov 16, 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) bug Something isn't working latex issue related to LaTeX backend priority:medium labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

The PR fixes the LaTeX list handler so that \item lines in an \input or \include file start new items of the open list. It moves the file reading into a new _read_input() method and splices the file nodes into the list body before the handler splits it into items.

Topic labels added: bug, latex, priority:medium.

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

1 related pull request(s) in the same code
PR State Signal Assessment
#4518 merged referenced as #4518 related: PR 4518 is merged. It added the item splitting and numbering in _process_list(), which this PR builds on. This PR fixes the \input case that 4518 left wrong and does not repeat its change.

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 e039453704. It read the code and did not run it.

I found no defect that must stop the merge. The change reads each \input file in a list body before it splits the body into items. It keeps the path-traversal, cycle and depth checks, and the new test covers the self-including file. The \input handler now calls _read_input() too, and it behaves as before.

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 16, 2026
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.96552% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/latex/handlers/macros.py 57.14% 14 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM
PeterStaar-IBM merged commit d706f75 into main Nov 19, 2026
34 checks passed
@PeterStaar-IBM
PeterStaar-IBM deleted the fix/latex-input-list-items branch November 19, 2026 05:58
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:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working latex issue related to LaTeX backend priority:medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants