Skip to content

Fix thumbnail embed nesting and missing-file captions, load the media module#43

Merged
JeroenDeDauw merged 6 commits into
masterfrom
fix/thumb-embed-followups
Jul 16, 2026
Merged

Fix thumbnail embed nesting and missing-file captions, load the media module#43
JeroenDeDauw merged 6 commits into
masterfrom
fix/thumb-embed-followups

Conversation

@JeroenDeDauw

@JeroenDeDauw JeroenDeDauw commented Jul 16, 2026

Copy link
Copy Markdown
Member

For #15

Fixes three of the four sub-items: the invalid <p><figure> nesting for a standalone thumb, the dropped caption on a missing-file thumb, and the unloaded mediawiki.page.media module. Sub-item 3 (non-inline media with thumb) and the deferred frame/frameless/alignment/border keywords stay out of scope, so this is a partial fix.

AI-authored — Claude Code, Opus 4.8 (max); detailed spec from @JeroenDeDauw, executed unattended; diff not yet human-reviewed; written test-first and mutation-checked, full PHPUnit + PHPStan/Psalm/phpcs green, all three fixes confirmed in live dev-wiki renders, independently AI-reviewed (correctness/security/design/edge-cases); CI green.

JeroenDeDauw and others added 6 commits July 17, 2026 01:16
For #15

A `thumb` embed alone on a line rendered as `<p><figure>...</figure></p>`. A
`<figure>` is flow content, invalid inside a phrasing-only `<p>`, so browsers
auto-close the paragraph and leave a stray empty `<p>` behind it. The HTML is
set directly on ParserOutput, so it never passes through RemexHtml to be fixed.

After parsing, a paragraph whose only content is a thumbnail file embed is now
replaced by the embed node itself, so its `<figure>` is emitted as a sibling of
the surrounding blocks, the way wikitext renders a standalone thumbnail. Embeds
sharing their paragraph with other content, and inline non-thumbnail embeds, are
left untouched, since they render as valid phrasing content in place.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
For #15

A `thumb` embed of a missing file fell through to the plain upload red link,
which is labelled only with the alt text, so the caption was silently dropped.

A missing file with `thumb` now goes through the same core thumbnail path as an
existing one, passing a false File. Core frames a broken-thumb box that keeps the
caption visible and puts the upload link inside, the way wikitext renders a
missing thumbnail. Missing files without `thumb` keep the bare upload link.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
For #15

Core's Linker::makeThumbLink2() registers mediawiki.page.media -- which powers a
thumbnail's magnify affordance -- only when passed a Parser, and the
ContentHandler render path has none, so the module was never loaded.

The FileEmbedRenderer port now exposes the module(s) a rendered thumbnail needs,
and the renderer adds them to the RenderedMarkdown modules whenever the document
embeds a thumbnail, mirroring how the code highlighter's modules are added only
for highlighted blocks. Metadata-only parses, which render no HTML, add nothing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
For #15

Promotion leaves a paragraph wrapped once it holds a second embed, but no test
exercised that guard, so a mutation dropping it survived. Add a case with two
thumbnail embeds in one paragraph asserting both stay wrapped, since promotion
handles only the solitary case.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The docblock claimed a thumbnail sharing its paragraph with other content is left
wrapped "since they render inline there". That holds for a plain inline image but
not for a thumbnail, whose block-level <figure> stays invalid inside the <p>. It
is left wrapped because this fix handles only the solitary case, so say that.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JeroenDeDauw
JeroenDeDauw marked this pull request as ready for review July 16, 2026 23:50
@JeroenDeDauw
JeroenDeDauw merged commit a8f833a into master Jul 16, 2026
12 checks passed
@JeroenDeDauw
JeroenDeDauw deleted the fix/thumb-embed-followups branch July 16, 2026 23:50
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.

1 participant