Page MenuHomePhabricator

Using VE to add a link to text that includes a template with <ref>, adds an unnecessary HTML blob
Open, LowPublic

Description

To reproduce:

  1. Edit a page in the English Wikipedia.
  2. Write potato. After this text, add a footnote using the {{refn}} template. (Not using the <ref> tag.) Wiki syntax will look like this: potato.{{refn|Also known as tater.}}
  3. Publish.
  4. Edit the page again.
  5. Highlight the text before the footnote, and the footnote.
  6. Click the Link button in the toolbar.
  7. Write The Potato Eaters as the link target. Click Done.
  8. Publish.

Observed: The published wikitext is [[The Potato Eaters|potato.{{refn|Also known as tater.}}]][./User:Amire80/ref+link#cite_note-1 <span class="mw-reflink-text"><nowiki>[1]</nowiki></span>]. You can see an example here.

Expected: The wikitext [./User:Amire80/ref+link#cite_note-1 <span class="mw-reflink-text"><nowiki>[1]</nowiki></span>] is definitely not supposed to be published.

This doesn't happen if instead of using {{refn}} you use an explicit <ref>. In this case the output will be [[The Potato Eaters|potato.]]<ref>Also known as tater.</ref>. This means that VE (or Parsoid) understands that a footnote is not supposed to appear in a link, and quietly truncates what the user highlighted. This is reasonable behavior, and it should also happen when {{refn}} is used.

In the English Wikipedia <ref> is much more common than {{refn}}, but it's still used on more than 20 thousand pages. In some other languages templates of this kind are very common (certainly so in Hebrew).

Event Timeline

This means that VE (or Parsoid) understands that a footnote is not supposed to appear in a link, and quietly truncates what the user highlighted. This is reasonable behavior, and it should also happen when {{refn}} is used.

No, Parsoid doesn't understand this, and there is nothing in wikitext that prevents a user from trying to link a ref tag. If an editor does that, the link does get broken up. Presumably, VE is preventing <ref> tags from being linked. But, VE canno know that a template should not be linked (because it *might* produce a <ref> tag ... or in the general case an <a> tag) without inspecting the full dom tree of a template. But, broadly generalizing, this is no a special case for <ref> tags or <a> tags, but more broadly figuring out content model restrictions in terms of what DOM nodes can be embedded in what nodes. I don't think VE has this generic logic or even special-case logic for <a> tags (presumably it has something for <ref> tags if you are saying it worked for you with <ref> tags).

Anyway, I see this as a feature request for VE and other editing tools to understand content model constraints (or for Parsoid to provide an API that clients like VE can query). But, for now, maybe VE can provide special case support by inspecting a DOM tree and prevent its linking in a wikilink if it contains <ref> tags or if it produces <a> tags.

Thanks for the explanation. As I noted in the description, I wasn't sure whether the truncating of the link before <ref> happens in VE or in Parsoid. I'm pretty sure that it happens somewhere.

It's not the most urgent issue to fix, but it does happen, and it would be nicer if it didn't.

This sounds a lot like T207303, or even the older T71876.

Yeah, possibly related, but I'm not sure it's the same.

One thing I'm sure of is that this bug here is easily reproducible :)

ssastry moved this task from Backlog to Future Ideas on the Parsoid board.