Last modified: 2013-01-15 01:32:03 UTC
In investigating bug 43089, we found that removing a link trail (i.e. [[Link]]s --> [[Link]]) is impossible in the VisualEditor. This is a Parsoid bug, can be reproduced with this command: echo "[[Link]]s" | node parse.js | sed 's/Links/blah/;' | node parse.js --html2wt This is a further result of our steadfast approach of "if the tests aren't broken, it's working" -- we didn't consider changes for a long time, and now that changes are possible, our hacks for roundtripping don't always work.... Suggested solution: 1. First try to find the initial link text (sans trail) in the current link text. If it's there, the new trail is whatever is left. 2. If that failed, try to find the old trail in the current text with a regex like /s$/. If you find it, emit it. 3. If both of those fail, don't emit a link trail. The trail has been modified enough that it's probably just within the text of the link now, and we won't lose meaning by just using the [[link|text]] syntax.
You can replicate this in VisualEditor in fact by removing the trailing 's' when the linked 's' came via a link-trail in the original wikitext. We record information about original wikitext in html-attributes. Recording source information in attributes and using it is not a hack -- it is necessary to preserve original wikitext when it is unmodified (which is going to be more often than not). We now need to fix our serialization to detect modifications in cases like this where we are currently not.
Change I126116de should fix this.
Finally squashed in https://gerrit.wikimedia.org/r/#/c/43985/.