mwparserfromhell
mwparserfromhell copied to clipboard
#if: magic word is not parsed correctly when tags are inside the argument
Consider this wikicode:
>>> w = mwparserfromhell.parse("foo{{#if:<nowiki>bar</nowiki>|true|false}}baz")
>>> print(w.get_tree())
foo{{#if:
<
nowiki
>
bar
</
nowiki
>
|true|false}}baz
The {{#if:...}}
magic word was clearly not parsed correctly, it is part of the surrounding text. It is probably because mwparserfromhell parses it as a regular template and tags are not allowed inside template names. However, MediaWiki allows tags inside the {{#if:...}}
magic word.
The same thing happens even when there are square brackets (without a link):
>>> w = mwparserfromhell.parse("foo{{#if:[bar]|true|false}}baz")
>>> print(w.get_tree())
foo{{#if:[bar]|true|false}}baz