Page MenuHomePhabricator

Set title attribute in inline images and support editing
Closed, ResolvedPublic

Description

The wikitext:

Foo [[File:Frisian flag.svg|simple caption|thumb]] bar

renders a <figure> with a caption, but the wikitext:

Foo [[File:Frisian flag.svg|simple caption]] bar

renders an <a><img> with no caption. MediaWiki's PHP parser renders the caption as the title attribute of the <a>. If the caption of an inline image contains wikitext, it's distilled down to plain text. For instance, try [[File:Frisian flag.svg|'''rich''' [[text]] in <table><tr><td>the</td><td>caption</td></tr></table>]] for instance.

For non-inline images, Parsoid behaves totally correctly, including the rendering of captions containing wikitext.


Version: unspecified
Severity: normal

Details

Reference
bz43836

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 1:34 AM
bzimport added a project: Parsoid.
bzimport set Reference to bz43836.
Catrope created this task.Jan 10 2013, 7:48 PM

Just setting the title attribute should be relatively straightforward (using tokensToString()). Making it editable in a way that handles non-text original content will need some thought though. Maybe HTML in an attribute, which we considered elsewhere?

Since this is pretty rare, we should probably simply shadow the plain-text attribute and support plain-text editing only. This would still preserve non-text captions when they are not edited, but will convert to plain-text caption with the first edit.

We are exposing the caption as editable HTML in data-mw. The title attribute for viewing can be set from that in a post-processing step. Please reopen if there are still issues with inline captions.

[Parsoid component reorg by merging JS/General and General. See bug 50685 for more information. Filter bugmail on this comment. parsoidreorg20130704]