sweble / sweble-wikitext

The Sweble Wikitext Components module provides a parser for MediaWiki's wikitext and an engine trying to emulate the behavior of a MediaWiki.
http://sweble.org/sites/swc-devel/develop-latest/tooling/sweble/sweble-wikitext
70 stars 27 forks source link

Expand `{{!}}` to `|` #47

Closed kno10 closed 7 years ago

kno10 commented 8 years ago

See https://www.mediawiki.org/wiki/Help:Magic_words#Other

Used to include a pipe character as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creating Template:! with | as the content.

From a quick test, simply expanding Template:! to | (instead of the soft-redirect that it is in Wikipedia now) appears to work.

Example of usage can be found e.g. in

https://en.wikipedia.org/wiki/Template:Geobox transcluded from https://en.wikipedia.org/wiki/Balomir_River_(Cugir)

hannesd commented 8 years ago

Hi! Do I understand you correctly: You are suggesting to adopt MediaWiki's MagicWord solution? Because you said yourself that the Template:! solution seems to work...

kno10 commented 8 years ago

I do not have a lot of experience yet, so I do not know what is best. I added a manual workaround (the default expansion does ''not'' work; I added an exception instead, that instead of returning the real contents of Template:! will return ' |' instead). I guess other users will experience the same problem.

hannesd commented 8 years ago

Thanks for the clarification. I'm not sure how the MediaWiki magic word mechanism works. I'll have to look into it. Due to the nature of the Sweble parser it will not be possible to recognize random strings as special entities without a bigger change to the parser pipeline. A quick and efficient solution would therefore be to hardcode the "{{!}}" detection in the parser code.

hannesd commented 7 years ago

Fixed in version 2.2.0