Page MenuHomePhabricator

Make VisualEditor remove automatic reference names when they get orphaned
Open, Needs TriagePublic

Description

VisualEditor automatically names references as :0, :1, :2, and so on the moment an unnamed reference is reused the first time. These names are never removed, even if one of the two usages is deleted and the reference is not reused anywhere any more. Why not do that?

Pro

  • We can easily identify automatic names (regex /^:\d+$/). Even if these names are not continuous, pasted from a different article, or even manually named, we are sure that removing them doesn't remove any useful information.
  • Removing the automatic name is just reversing the operation when the name was added and should not come as a surprise – at least not be more surprising than the moment the name was added.
  • It will only be done when the edit actually touches that reference. The diff will clearly show why the name was removed.

Con

  • When one of the two usages is cut and immediately pasted somewhere else in the same article, it should not be renamed, but probably will when this suggestion is implemented.
  • Could be considered a "dirty diff", depending on how you look at it.

Event Timeline

When a reference is reused inside a template transclusion, we can't detect that (even Parsoid loses the information sometimes: T150612), so removing or changing any reference names risks damaging articles where they're reused in templates.

That should be extremely rare (how would a template know how a reference in the normal article body is named?), but definitely be considered a blocker for this here. Thanks! I hope we can fix this, as well as T87134.

That should be extremely rare (how would a template know how a reference in the normal article body is named?)

Usually it'd be in a parameter of the template – when editing in wikitext mode, people can re-use a reference in e.g. an infobox or in a multi-column section, generated by a template.

There are also templates like https://en.wikipedia.org/wiki/Template:R often used interchangeably with <ref>.