# The parsoid-compatible option below is only relevant when we are running # parser tests in integrated mode with Parsoid. This option is ignored # when this test file is run with Parsoid in standalone mode. !! options parsoid-compatible=wt2html,wt2wt version=2 !! end !!article Foo !!text FOO !!endarticle !! article Template:1x !! text {{{1}}} !! endarticle !!article Template:Bullet !!text *Bar !!endarticle !! article Template:Precedence5 !! text {{{{{1}}}}} !! endarticle !! article Template:Preprocessor_precedence_9 !! text ;4: {{{{1}}}} ;5: {{{{{2}}}}} ;6: {{{{{{3}}}}}} ;7: {{{{{{{4}}}}}}} !! endarticle !! article Template:Preprocessor_precedence_10 !! text ;1: -{R|raw}- ;2: -{{Bullet}}- ;3: -{{{1}}}- ;4: -{{{{2}}}}- ;5: -{{{{{3}}}}}- ;6: -{{{{{{4}}}}}}- ;7: -{{{{{{{5}}}}}}}- !! endarticle ### ### Preprocessor precedence tests ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF ### ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]] !! test Preprocessor precedence 1: link is rightmost opening !! options parsoid=wt2html !! wikitext {{[[Foo|bar}}]] But close-brace is not a valid character in a link title: {{[[Foo}}|bar]] However, we can still tell this was handled as a link in the preprocessor: {{1x|[[Foo}}|bar]]|bat}} !! html/php

{{bar}}

But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]

However, we can still tell this was handled as a link in the preprocessor: [[Foo}}|bar]]

!! html/parsoid

{{bar}}

But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]

However, we can still tell this was handled as a link in the preprocessor: [[Foo}}|bar]]

!! end !! test Preprocessor precedence 2: template is rightmost opening !! options language=zh !! wikitext -{{1x|foo}-}}- !! html/php

-foo}--

!! html/parsoid

-foo}--

!! end !! test Preprocessor precedence 3: language converter is rightmost opening !! options language=zh parsoid=wt2html !! wikitext {{1x|hi}} {{-{R|1x|hi}}}- [[-{R|raw]]}- !! html/php

hi

{{1x|hi}}

[[raw]]

!! html/parsoid

hi

{{

[[

!! end !! test Preprocessor precedence 4: left-most angle bracket !! options language=zh !! wikitext !! html/php !! html/parsoid !! end !! test Preprocessor precedence 5: tplarg takes precedence over template !! wikitext {{Precedence5|Bullet}} !! html/php !! html/parsoid !! end !! test Preprocessor precedence 6: broken link is rightmost opening !! options parsoid=wt2html !! wikitext {{1x|[[Foo}} {{1x|[[Foo|bar|bat=baz}} !! html/php

{{1x|[[Foo}}

{{1x|[[Foo|bar|bat=baz}}

!! html/parsoid

{{1x|[[Foo}}

{{1x|[[Foo|bar|bat=baz}}

!! end # This next test exposes a difference between PHP and Parsoid: # Given [[Foo|{{1x|Bar]]x}}y]]z: # 1) Both PHP and Parsoid ignore the `]]` inside the `1x` in the # "preprocessor" stage. The `{{1x` extends until the `x}}`, and the # outer `[[Foo` extends until the `y]]` # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an # intermediate result (after template expansion), and link processing # happens on this intermediate result, which moves the wikilink # boundary leftward to `[[Foo|Bar]]` # 2b) Parsoid works in a single step, so it's going to keep the # wikilink as extending to the `y]]` # 3a) Then PHP does linktrail processing which slurps up the trailing # `xy` inside the link. # 3b) Parsoid will do linktrail processing to slurp up the trailing # `z` inside the link. # This is "correct" behavior. Parsoid's basic worldview is that the # `]]` inside the template shouldn't be allowed to leak out to affect # the surrounding wikilink. PHP may match Parsoid (in the future) # if you use {{#balance}} (T114445). !! test Preprocessor precedence 7: broken template is rightmost opening !! options parsoid=wt2html !! wikitext [[Foo|{{1x|Bar]] [[Foo|{{1x|Bar]]-x}}-y]]-z Careful: linktrails can move the end of the wikilink: [[Foo|{{1x|y']]a}}l]]l !! html/php

{{1x|Bar

Bar-x-y]]-z

Careful: linktrails can move the end of the wikilink: y'al]]l

!! html/parsoid

[[Foo|{{1x|Bar]]

Bar]]-x-y-z

Careful: linktrails can move the end of the wikilink: y']]all

!! end !! test Preprocessor precedence 8: broken language converter is rightmost opening !! options language=zh !! wikitext [[Foo-{R|raw]] !! html

[[Foo-{R|raw]]

!! end !! test Preprocessor precedence 9: groups of braces !! wikitext {{Preprocessor precedence 9|Four|Bullet|1|2}} !! html/php
4
{Four}
5
6
Four
7
{Bullet}
!! html/parsoid+standalone
4
{Four}
5
6
Four
7
{Bullet}
!! html/parsoid+integrated
4
{Four}
5
6
Four
7
{Bullet}
!! end !! test Preprocessor precedence 10: groups of braces with leading dash !! options language=zh !! wikitext {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}} !! html/php
1
raw
2
-
3
-Three-
4
raw2
5
-
6
-Three-
7
raw2
!! html/parsoid+standalone
1
2
-
3
-Three-
4
5
-
6
-Three-
7
!! html/parsoid+integrated
1
2
-
3
-Three-
4
5
-
6
-Three-
7
!! end !! test Preprocessor precedence 11: found during visual diff testing !! wikitext {{#tag:span|-{{#tag:span|-{{1x|x}}}}}} {{1x|-{{1x|-{{1x|x}}}}}} {{1x|-{{1x|x}}}} !! html/php

--x

--x

-x

!! html/parsoid

--x

--x

-x

!! end # FIXME: In integrated mode, the preprocessor returns {{1x|foo-{bar}bat}} # and doesn't expand it. This is a difference with legacy processing and could lead to # edge-case rendering diffs on pages wit broken language converter markup. # For now, we'll leave te integrated mode test as a known failure, but this isn't # very high priority to fix. !! test Preprocessor precedence 12: broken language converter closed by brace. !! options parsoid=wt2html !! wikitext This form breaks the template, which is unfortunate: *{{1x|foo-{bar}bat}} But if the broken language converter markup is inside an extension tag, nothing bad happens: *foo-{bar}bat *{{1x|foo-{bar}bat}} *
foo-{bar}bat
*{{1x|
foo-{bar}bat
}} foo-{bar}bat {{1x|foo-{bar}bat}} !! html/php

This form breaks the template, which is unfortunate:

But if the broken language converter markup is inside an extension tag, nothing bad happens:

'foo-{bar}bat'
array (
)
'foo-{bar}bat'
array (
)
!! html/parsoid

This form breaks the template, which is unfortunate:

But if the broken language converter markup is inside an extension tag, nothing bad happens:

'foo-{bar}bat'
array (
)
'foo-{bar}bat'
array (
)
!! end !! test Preprocessor precedence 13: broken language converter in external link !! options parsoid=wt2html !! wikitext *[http://example.com/-{foo Example in URL] *[http://example.com Example in -{link} description] *{{1x|[http://example.com/-{foo Breaks template, however]}} !! html/php !! html/parsoid !! end ## Parsoid integrated mode will drop all comments in templates & template args !! test Preprocessor precedence 14: broken language converter in comment !! wikitext *...should be ok *...extra dashes *{{1x|foobat}}...should be ok !! html/php !! html/parsoid+standalone !! html/parsoid+integrated