Page MenuHomePhabricator

In VisualEditor, creating unpiped hyperlinks then italicising or bolding them forces a piped link
Open, Needs TriagePublic

Description

This issue has been ongoing since at least 2018, as reported in T191700 and by me in April 2018.

To reproduce:

  1. Edit a page in VisualEditor.
  2. Type a name of a page.
  3. Add a hyperlink to that page (click the chain icon, then click Done or the article name in the list).
    • Switch to source editor and see that the link forms like [[Example]], then switch back to VisualEditor.
  4. Select the new link and press Ctrl+I or Ctrl+B to turn it italic or bold (will use italic as example).
    • Switch back to source editor. It is now [[Example|''Example'']].

The frustrating workaround I have been using for 2 years is as follows:

  1. Un-hyperlink the word.
  2. Italicise the word first.
  3. Re-hyperlink the word.
    • Now it looks like ''[[Example]]''.

I recently noticed some progress in this bug. I found out (unrelated) that editing the text of an unformatted hyperlink then changing it back to the original text now unpipes the link, which is functionality I had been waiting for. It turns out this also applies to links applied to text after formatting, as above. It goes like this:

  • Complete steps 1–9
  1. Add a character in the text of the link (like "Examfple").
    • Switch to source editor. It now looks like ''[[Example|Examfple]]''. Switch back to VisualEditor.
  2. Remove the character so the text is back to being the same as the link.
    • Switch to source editor. It now looks like ''[[Example]]'', which is amazing.

You can actually mix both of these behaviours by applying italics before hyperlink and bold after hyperlink. Then it gets really ridiculous. You will see '[[Example]]'' change to ''[[Example|'''Example''']]'' and back to ''[[Example]]''.

Interesting trivia

VisualEditor force-capitalises the hyperlink the first time you change it to italics or bold, but if you un-italicise it and italicise it again, every other time after that it will insert a lowercase link. I.e.:

  • [[example]]
  • [[Example|''example'']]
  • [[example]]
  • [[example|''example'']]
  • [[example]]
  • [[example|''example'']]

I was told in 2018 that this issue was addressed/couldn't easily be fixed. I wholly refuse to believe that.

Event Timeline

JTannerWMF subscribed.

Based on our team's current priorities, we are constrained to fixing bugs that severely impact multiple users ability to edit.

I was told in 2018 that this issue was addressed/couldn't easily be fixed. I wholly refuse to believe that.

I promise that it is difficult to address. It's because of the internal data model and algorithms used by VisualEditor.

Let me try to give a quick example. Let's consider your example of having an italicized link, like this:

This is an example text

If I was writing that in wikitext (or in HTML, or in the funny markup language I used here on Phabricator), I'd need to decide which formatting is applied first, either ''[[example]]'' or [[Example|''example'']]. In visual editor, we don't store the order in which "annotations" (any text formatting) are applied, the data looks like this (see also https://www.mediawiki.org/wiki/VisualEditor/Design/Software_overview#Data_structures):

TextThisisanexampletext
AnnotationsA,BA,BA,BA,BA,BA,BA,B
AnnotationsA = italicB = link(Example)

You might say, well, just apply A and B in the right order when converting to HTML. Unfortunately the right order is not obvious, and we can't even make a good guess without examining the entire page – but our converter code currently can't "look ahead", it only considers the current character and the formatting applied before that.

TextThisisanexampletext
AnnotationsAAAA,BA,BBBBBBBBB
AnnotationsA = italicB = link(Example)

As soon as we transition from "A" to "A,B", we have to decide in which order to put A and B, and we don't know which is the ideal order unless we look ahead to see when each annotation ends, and our current system can't do that.

My best idea to improve the current behavior was always applying links last (making them "innermost" annotations), which helps in the first example, but fails in the second one. It would result in This ''is [[example|an]]'' [[example]] text, while the ideal result would probably be This ''is'' [[example|''an'' example]] text.