Page MenuHomePhabricator

Media option caption parsing is fragile
Open, NormalPublic

Description

Parsing of captions for media is fragile: anything which can't get parsed as a valid image option becomes a candidate for the caption, with the last one specified being somewhat arbitrarily chosen.

That means we can't every add extra image options or change the translation of image options with perfect safety. There's always the chance that:

[[File:One.jpg|one=the loneliest number]]

will lose its caption someday as soon as one becomes a valid image option (or translation of an image option).

I propose making this more robust in two ways:

  1. \s\w+\s= should always parse as an image option, never a caption. This carves out some space for safely adding additional options in the future. We will have to lint any existing captions of this form, rewriting them.
  2. We should add a new option caption, which explicitly sets a caption. Then you can explicitly set a caption (even if it would otherwise look like an image option!) by using: [[File:One.jpg|caption=one=the loneliest number]].

In order to fixup any existing "option-like" captions found during linting in step 1, you could rewrite as [[File:One.jpg|<nowiki/>1=the loneliest number]], [[File:One.jpg|1<nowiki>=</nowiki>the loneliest number]] or [[File:One.jpg|caption=1=the loneliest number]].

Event Timeline

cscott created this task.Apr 21 2017, 8:05 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 21 2017, 8:05 PM
ssastry triaged this task as Normal priority.Apr 21 2017, 8:35 PM
ssastry awarded a token.
This comment was removed by Arlolra.

Whoops, the removed comment was basically to note that there're other supported valued option formats. See T162961