mwparserfromhell icon indicating copy to clipboard operation
mwparserfromhell copied to clipboard

Template incorrectly parsed when {{!}} is used

Open JJMC89 opened this issue 8 years ago • 1 comments

In this revision of ru:Template:Магнитогорск — Тобол {{Маршрутная карта}}'s |1= shows as \n\\CONTgq\\STR+r~~[[Однопутная система движения|↕]][[Электрификация железных дорог|нет]]~~ ~~{{rmri|L|Шаблон:Белорецк — Сибай}} на {{ст.|Сибай}}\n\\\\CONT2\\STR+c3\\~~ ~~ ~~ ~~Служебные пути ОАО «ММК»\n\\\\STRc1\\KRZ2+4u\\STRc3\n\\\\\\STR2!~STRc1\\v-STR+4!~STRc3\n\\\\\\exENDEa!~STRc1\\v-STR!~vSTR+4-\n\\\\\\ENDExa!~STRc2\\v-STR!~vSTR3-\n\\\\\\ABZg+1!~SEC1\\v-STR!~STRc4~~{{BSsplit{{!}}[[Электрификация железных дорог|нет]]{{!}}[[Переменный ток|≈]][[Электрификация железных дорог|25кВ]] instead of the much longer value in the wikitext.

Abbreviated code:

    def treat_page(self):
        """Process one page."""
        # Replace tags to prevent parsing issues.
        text, mask = mask_html_tags(self.current_page.text)
        wikicode = mwparserfromhell.parse(text, skip_style_tags=True)
        for tpl in wikicode.ifilter_templates():
            if tpl.name.matches('Маршрутная карта'):
                for param in tpl.params:
                    # This is where param.value is truncated for |1=.
                    param_value = str(param.value)

Complete code

JJMC89 avatar Sep 17 '17 19:09 JJMC89

This appears to be related to the use of the {{!}} magic word.

JJMC89 avatar Sep 18 '17 01:09 JJMC89