Page MenuHomePhabricator

Image captions should ignore paragraph tags
Open, LowPublic

Description

Add linebreaks to a caption in wikitext doesn't generate <p> tags, so adding <p> tags shouldn't generate linebreaks.

Currently
...<figcaption><p>FOO</p></figcaption>... -> [[File:Foo.jpg|\nFOO\n]] ->
whereas
[[File:Foo.jpg|\nFOO\n]] -> ...<figcaption>\nFOO\n</figcaption>...

Should be
...<figcaption><p>FOO</p></figcaption>... -> [[File:Foo.jpg|FOO]] ->

The HTML above is generated if the user adds content to an empty caption in VE.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 12 2018, 12:46 PM
ssastry assigned this task to Sbailey.Mar 15 2018, 8:19 PM
ssastry triaged this task as Normal priority.

What happens if there are multiple paragraph tags? What is the editor intention there? @Sbailey and I were discussing this and we are going to just run them together with a single space.

This is ignoring the broader discussion we were having today about loosening some restrictions -- that is a different thread to be picked up later.

Change 420615 had a related patch set uploaded (by Sbailey; owner: Sbailey):
[mediawiki/services/parsoid@master] Image captions ignore paragraph tags

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

What happens if there are multiple paragraph tags? What is the editor intention there? @Sbailey and I were discussing this and we are going to just run them together with a single space.

That's fine with us. We're doing our best to prevent users from inputting more than one line at the moment.

Ed, Subbu and I have discussed that for multiple p tags in the caption, we will be replacing the new lines with a single space, merging the captions together. The hope is that the captions would be sentences and that joining them with a space will be a reasonable way to "fix" this situation.

The first submission of the patch just fixes the single case.

Change 420615 merged by jenkins-bot:
[mediawiki/services/parsoid@master] html2wt: Image captions ignore paragraph tags

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

ssastry moved this task from Backlog to html2wt on the Parsoid board.Mar 26 2018, 11:00 PM
ssastry lowered the priority of this task from Normal to Low.Apr 2 2018, 7:17 PM

The main part of this ticket, as it affects VE, is done now and will be deployed when we push out code next. So, if there is a single p-tag, we handle that properly.

Se could also handle the case more generally to also suppress newlines when there are multiple p-tags. That work is yet to be done. But it is lower priority since VE doesn't introduce multiple p-tags during editing sessions.

Adding a second patch to handle multiple paragraphs being collapsed in a figcaption.

https://gerrit.wikimedia.org/r/#/c/423818/

Change 425726 had a related patch set uploaded (by Arlolra; owner: Arlolra):
[mediawiki/core@master] [WIP] Remove newline stripping from image captions

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