A convenience feature present in MediaWiki's link handling is the inclusion of trailing letters after the wikilink into the link label (see https://www.mediawiki.org/wiki/Help:Links#linktrail), effectively forming a piped link with a much cleaner syntax:
[[link]]s
behaves the same as
[[link|links]]
Experimentation suggests that all trailing lower-case ASCII alphabet letters are affixed to the link label, though the above MediaWiki page suggests the set of matched letters is language specific.
For the present purpose, however, it should be enough to adjust the regex in line 42 to
/\[\[([\w\s/]+)(\|([\w\s/]+))?\]\]([a-z]*)/
and then append match[4] to the label in the following lines.
One potential downside
With this approach, it becomes harder to prevent trailing letters from being absorbed into the link, should that not be desired, e.g. for [[GPL]]v3. WikiMedia hacks around this with an empty <nowiki /> tag, but no such do-nothing marker exists in Markdown. To resolve this, I propose that piped links should instead leave trailing letters where they are. In the present example, we could then recover the existing behavior with
[[GPL|GPL]]v3
(MediaWiki, on the other hand, still absorbs trailing letters into piped link labels, though it is not immediately clear why they should: one could simply move the trailing letters inside the closing brackets in that case.) If this seems too verbose, one can even imagine a shorthand like [[|GPL]]v3 (though this means something else in Wikipedia).
A convenience feature present in MediaWiki's link handling is the inclusion of trailing letters after the wikilink into the link label (see https://www.mediawiki.org/wiki/Help:Links#linktrail), effectively forming a piped link with a much cleaner syntax:
behaves the same as
Experimentation suggests that all trailing lower-case ASCII alphabet letters are affixed to the link label, though the above MediaWiki page suggests the set of matched letters is language specific.
For the present purpose, however, it should be enough to adjust the regex in line 42 to
and then append
match[4]
to the label in the following lines.One potential downside
With this approach, it becomes harder to prevent trailing letters from being absorbed into the link, should that not be desired, e.g. for
[[GPL]]v3
. WikiMedia hacks around this with an empty<nowiki />
tag, but no such do-nothing marker exists in Markdown. To resolve this, I propose that piped links should instead leave trailing letters where they are. In the present example, we could then recover the existing behavior with(MediaWiki, on the other hand, still absorbs trailing letters into piped link labels, though it is not immediately clear why they should: one could simply move the trailing letters inside the closing brackets in that case.) If this seems too verbose, one can even imagine a shorthand like
[[|GPL]]v3
(though this means something else in Wikipedia).