Page MenuHomePhabricator

VisualEditor breaks galleries with <br /> in image captions
Closed, ResolvedPublic

Description

As reported on the German-language Wikipedia's feedback page, editing a gallery which has <br /> linebreaks within the image captions destroys the gallery.

An example of how to reproduce the problem is given here.

Enforcing line-breaks within the captions using <br /> might not be allowed within gallery captions, but it works well and is therefore used by editors. Even if VE does not support adding linebreaks, it should not destroy already existing galleries when users edit the page.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

So, this clearly shouldn't happen, and the visual editor is mangling the wikitext. But, at the same time, putting a line break in an image caption is almost always a bad idea. Different people have different font sizes, screen sizes, resolutions, and so on, and all of this means that trying to force line breaks to appear in particular spots in a size-constrained element of a web page is recipe for disaster and cause a lot of unpredictability for readers.

Esanders subscribed.

This appears to be a Parsoid bug. Captions with a <br> don't round-trip cleanly (if data-parsoid.body is empty).

Arlolra triaged this task as Medium priority.

Change 423984 had a related patch set uploaded (by Arlolra; owner: Arlolra):
[mediawiki/services/parsoid@master] Serialize gallery image captions in single line context

https://gerrit.wikimedia.org/r/423984

But, at the same time, putting a line break in an image caption is almost always a bad idea.

I agree, but as long as <gallery> permits the use of line breaks, the VE needs to as well. Perhaps <gallery> can be restricted to plain text with only basic formatting (bold, italics, link)?

Change 423984 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Serialize gallery image captions in single line context

https://gerrit.wikimedia.org/r/423984