Skip to content

fix(latex): skip minted's language and bracketed options before code - #4544

Open
ankit2235 wants to merge 1 commit into
docling-project:mainfrom
ankit2235:fix/latex-code-env-arguments
Open

ankit2235 wants to merge 1 commit into
docling-project:mainfrom
ankit2235:fix/latex-code-env-arguments

Conversation

@ankit2235

@ankit2235 ankit2235 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

_extract_verbatim_content only skipped an optional [...] after \begin{env}, using a non-greedy \[.*?\]. Two cases leaked markup into the code item:

  • minted takes a mandatory language argument, which became the first line of the code: \begin{minted}{python} gave {python}\nx = 1.
  • An lstlisting option value containing ], such as caption={A [nested] cap}, ended the option match early and left cap}] in the code.

The pattern now skips an optional argument whose {...} values may contain brackets, and, for minted only, the {language} argument after it. verbatim, plain lstlisting, multi-line options, and code that itself starts with [ or { behave as before.

The new parametrized test covers minted with and without options and lstlisting with a bracketed caption, with an indented code line so the first-line indentation from #4502 stays covered. It fails on main and passes with this change; the other LaTeX tests pass unchanged.

Using minted's language (or lstlisting's language=) as the code item's language is left for a follow-up.

Issue resolved by this Pull Request:
Resolves #4542

Checklist:

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

Signed-off-by: Ankit Kumar <ankitkumar19473@gmail.com>
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Oct 3, 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 Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

LaTeX backend leaks minted's language argument and bracketed lstlisting options into the code

1 participant