Page MenuHomePhabricator

Visual editor breaks labeled sections, invisibly removes line breaks
Closed, ResolvedPublic

Description

Hi, all, I came across an issue on enwiki where an editor had moved the content of a labeled section that other pages were using labeled section transclusion to populate from. The edit in question is https://en.wikipedia.org/w/index.php?title=Western_African_Ebola_virus_epidemic&diff=prev&oldid=943623521; this change broke the labeled section transclusion that pages such as https://en.wikipedia.org/wiki/Zaire_ebolavirus use to populate case and death counts from a centralized location. (The edit also removed the line break between paragraphs.)

After reverting the change, I noticed that it was tagged as a Visual Editor tag and realized that it was likely a bug in Visual Editor rather than a conscious action on the editor's part. I enabled Visual editor and, sure enouh, was able to recreate the exact bug.

Steps to recreate:

  1. Navigate to https://en.wikipedia.org/wiki/Western_African_Ebola_virus_epidemic and enter the Visual Editor.
  2. Make an arbitrary change to the first paragraph (the original user moved the (2013-2016) to in front of the bolded text, but in my testing, even simply adding a space and then immediately deleting it triggered the bug).
  3. (this step isn't necessary to trigger the bug; it is jsut a way to observe the effect without saving the page) Switch to source editor and observe the changes; the <section start /> and <section end/> tags have been moved to the end of the first paragraph while leaving their content behind, which breaks the labeled section transclusion, and the line break between the first and second paragraphs have been removed. This line break has been removed from the source even though its removal was *not* reflected in the original Visual Editor screen.

I am using Firefox 68.4.1 ESR on Windows 10, with the Monobook skin. I can't say what the original editor's sstem info is, obviously.

Event Timeline

Looks like <section> tags are incorrectly treated as "meta" nodes, instead of "alien extension" nodes.

For reference:

  • Meta nodes are those for which it doesn't matter exactly where the syntax is placed, because it affects the entire article, e.g. [[Category:...]] or __NOTOC__ or {{DISPLAYTITLE:...}}. Obviously this is not true for <section>, their placement determines the contents of the LST section.
  • Alien extension nodes are tags defined by MediaWiki extensions, for which we don't have editing tools in the editor. One other example would be <timeline>, there are a few more but it's mostly weird stuff that isn't used in normal articles.

Note that there's an old task about implementing support for LST: T72581. I don't think we'll be able to work on that, this task should be limited to not breaking existing articles.

Change 577350 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] ve.dm.MWAlienMetaItem: Never match mw:Extension nodes

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

This patch would fix this issue, but I'm not sure if it might have any bad consequences elsewhere. We might need to think about this a bit more.

The effect would be like this, with the "<> section" markers appearing in visual mode wherever the tag is used:

image.png (2,149×413 px, 207 KB)

(Also, this seems like a terrible editing experience in both wikitext and visual mode, and if anyone asked for my opinion, I would suggest never using <section> tags and instead putting the data that must be reused between multiple articles in a template.)

I would suggest never using <section> tags and instead putting the data that must be reused between multiple articles in a template.

Yes, that's what I advise, too.

I'm far from an expert at the intricacies of magic word/template/whatever parsing here, but the enwiki help page suggests that such a template isn't possible: https://en.wikipedia.org/wiki/Help:Labeled_section_transclusion#No_template.

(using a template was my first thought, too, trust me :) )

(Also, this seems like a terrible editing experience in both wikitext and visual mode, and if anyone asked for my opinion, I would suggest never using <section> tags and instead putting the data that must be reused between multiple articles in a template.)

I don't think <section begin=number />1234<section end=number /> is worse than {{article-metadata|number}} with the metadata template having some terrible switch statement to output 1234 for the argument number. Or a Lua module that extracts data from Wikidata or Commons.

With LST, all you have to do is to ignore the section tags, but you actually can edit the data directly. With templates you first have to find the source where the data comes from and edit it there, and both finding the source and editing that data (perhaps with a different editor than you are used to) can be hard.

Change 577350 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] ve.dm.MWAlienMetaItem: Never match mw:Extension nodes

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