Page MenuHomePhabricator

Visual editor shouldn't add the File: prefix when missing in a gallery
Open, MediumPublic

Description

<gallery> can be filled with images with the File: prefix, or without it.

When VE opens a page where a gallery has images with no prefixes, it adds prefixes. This bothers people who use wikitext (feedback) because it "complexifies the code".

Would it be possible to have VE not adding the prefixes when they are omitted in the wikitext?

The other solution would be to remove the ability to have galleries displayed without the prefix, to have consistency on how images are displayed.

Event Timeline

The documentation recommends that the "File:" prefix be used: https://en.wikipedia.org/wiki/Help:Gallery_tag#Syntax. It may be possible for Parsoid to preserve the prefix with, but I think it would just to be consistent everywhere.

This is probably a VE issue rather than Parsoid issue. See also T207620 (duplicate?).

The documentation recommends that the "File:" prefix be used: https://en.wikipedia.org/wiki/Help:Gallery_tag#Syntax.

A quick note concerning the documentation - please don't quote English Wikipedia but use MediaWiki doc instead. That doc is supposed to be more neutral and up to date (in theory).

This is probably a VE issue rather than Parsoid issue.

If you round-trip gallery syntax without File: prefixes, and remove the wikitext body, the File: prefixes get added back in, so it is a Parsoid issue.

and remove the wikitext body

You can also pass --nativeGallery to avoid emitting that.

https://github.com/wikimedia/parsoid/blob/master/lib/ext/Gallery/index.js#L325-L334

But we should probably consider making that the default now that VE has html editing support for galleries.

Here's a list of pages with gallery normalizations to explore,
https://phabricator.wikimedia.org/P8032

ssastry triaged this task as Medium priority.Jun 10 2019, 8:43 PM
ssastry edited projects, added Parsoid-Edit-Support; removed Parsoid.
Thibaut120094 renamed this task from VE shouldn't add the File: prefix when missing in a gallery to Visual editor shouldn't add the File: prefix when missing in a gallery.Dec 29 2019, 12:10 PM
Thibaut120094 subscribed.

You can also pass --nativeGallery to avoid emitting that.

How can we do this in the API?

You can also pass --nativeGallery to avoid emitting that.

That flag was removed in,
https://github.com/wikimedia/parsoid/commit/e748b8ec831bf6c86487ca8e551274d62be16b1d

How can we do this in the API?

Parsoid defaults to using native galleries now,
https://github.com/wikimedia/parsoid/blob/master/src/Config/SiteConfig.php#L158

However, it's disabled in the extension,
https://github.com/wikimedia/parsoid/blob/master/extension/src/Config/SiteConfig.php#L175

so you'd need to change that hardcoded value.

Unfortunately, we still need the signal from the explicit removal of extsrc when a gallery is edited because of T214648

LGoto moved this task from Backlog to Needs Investigation on the Parsoid board.
Arlolra moved this task from Needs Investigation to Bugs & Crashers on the Parsoid board.

Change 891924 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Roundtrip file prefix in galleries

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

Change 891924 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Roundtrip file prefix in galleries

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

Change 894720 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/vendor@master] Bump parsoid to 0.17.0-a19

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

Change 894720 merged by jenkins-bot:

[mediawiki/vendor@master] Bump parsoid to 0.17.0-a19

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

Parsoid has the ability to avoid this normalization now,

> echo "<gallery>\nTest.jpg\n</gallery>" | php bin/parse.php --wt2wt 
<gallery>
Test.jpg
</gallery>

but there's work left to be done on VE's end as explained in T329662#8738877