# 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/phphi
{{1x|hi}}
[[raw]]
!! html/parsoidhi
{{
[[
!! 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{{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/phpBar-x-y]]-z
Careful: linktrails can move the end of the wikilink: y'al]]l
!! html/parsoid[[Foo|{{1x|Bar]]
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--x
--x
-x
!! html/parsoid--x
--x
-x
!! end # FIXME: In integrated mode, the preprocessor returns {{1x|foo-{bar}bat*{{1x|
foo-{bar}bat}}
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
foo-{bar}bat
'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
foo-{bar}bat
'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
1
2
3
4
5
6
!! html/parsoid1
2
3
4
5
6
!! end !! test Preprocessor precedence 16: matching closing braces to opening braces !! options language=zh parsoid=wt2html !! wikitext -{{{1x|foo}}bar}- !! html/phpfoobar
!! html/parsoid!! end !! test Preprocessor precedence 17: template w/o target shouldn't prevent closing !! options parsoid=wt2html !! wikitext {{1x|hi {{}}}} !! html/php
hi {{}}
!! html/parsoidhi {{}}
!! end # Ensure we're using a language without variants for this test; even # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily. !! test Preprocessor precedence 18: another rightmost wins scenario !! options parsoid=wt2html language=de !! wikitext {{ -{{{{1|tplarg}}} }} }- !! html/php{{ -{tplarg }} }-
!! html/parsoid{{ -{tplarg }} }-
!! end !! test Preprocessor precedence 19: break syntax !! options parsoid=wt2html !! wikitext -{{ !! html/php-{{
!! html/parsoid-{{
!! end ## Regression test for Parsoid !! test Language converter over extlink !! wikitext {{1x | [-{oh no]}-] }} !! html/php[-{oh no]}-]!! html/parsoid
[-{oh no]}-]!! end