Skip to content

fix(mediawiki): convert gallery entries to pictures - #5785

Open
pinjun99 wants to merge 1 commit into
docling-project:mainfrom
pinjun99:oss/5784
Open

pinjun99 wants to merge 1 commit into
docling-project:mainfrom
pinjun99:oss/5784

Conversation

@pinjun99

@pinjun99 pinjun99 commented Dec 6, 2026

Copy link
Copy Markdown

Resolves #5784

In the MediaWiki backend, <gallery> is a parser extension tag, so its body reaches _render_tag() as plain text and every entry came out as a text line (File:A.jpg|Caption A File:B.jpg) with no picture.

This change treats gallery as a block tag and renders each File: / Image: line as if it were a [[File:...]] link, so gallery entries become pictures with the same captions a file link outside a gallery gets. Lines without a file namespace, with an empty filename, or that do not parse as a single link are skipped. The per-entry parsing uses the same tokenizer work budget as the rest of the document.

Found while testing the MediaWiki backend with Codex; I reviewed the diff and ran the tests.

Checklist:

  • Documentation has been updated, if necessary. (one sentence in docs/usage/supported_formats.md)
  • Examples have been added, if necessary. (not needed)
  • Tests have been added, if necessary.

Review evidence:

  • Before (main a0bd015): the issue's example prints File:A.jpg|Caption A File:B.jpg and 0 pictures.
  • After: two pictures (captions A link and B.jpg in the test), and the Markdown export matches the same content written as [[File:...]] links.
  • New tests test_mediawiki_gallery_matches_file_links, test_mediawiki_gallery_skips_invalid_entries, test_gallery_entries_share_the_tokenizer_work_budget: 3 failed on main with only the test change, 3 passed with the fix.
  • pytest tests/test_backend_mediawiki.py: 75 passed, 1 failed. The failure (test_mediawiki_cli_can_convert_a_directory, "No module named 'torch'") also fails on unmodified main on my machine, which has no torch installed.
  • ruff check and ruff format --check on the changed files: clean.
  • Not run: make validate / prek, ty, the full test suite.

Signed-off-by: Ooi Pin Jun <pinjun15@gmail.com>
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Dec 6, 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 bug Something isn't working xml issue related to supported schema-specific XML formats labels Dec 6, 2026
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

Warning

The AI analysis did not finish. Only the deterministic checks are shown.

Topic labels added: bug, xml.

CI safety: not assessed.

Possibly related pull requests

PR State Signal Assessment
#5779 open changes the same code not assessed
#5777 open changes the same code not assessed

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

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

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.

MediaWiki: the pictures of a <gallery> block are kept as raw text lines, not as pictures

1 participant