# Tests of Parsoid PFragment Handlers # TODO (T390343): wt2wt/html2wt modes should be enabled in parsoid-compatible !! options parsoid-compatible=wt2html version=2 !! end !! article Template:1x !! text {{{1}}} !! endarticle !! article Foo !! text Define [[Foo]] to avoid a red link !! endarticle !! article FOO !! text #REDIRECT [[Foo]] !! endarticle !! test f1_wt: Basic parser function test !! options parsoid=wt2html,wt2wt !! wikitext {{#f1_wt:foo|bar}} {{#f1_wt:foo|''bar''}} !! html/parsoid

foo bar

foo bar

!! end !! test f1_wt: Nested template for an arg !! options parsoid=wt2html,wt2wt !! wikitext {{#f1_wt:foo|1|{{1x|A}}|2}} !! html/parsoid

foo 1 A 2

!! end !! test f1_wt: Multi-level nesting of templates and parser functions !! options parsoid=wt2html,wt2wt !! wikitext {{#f1_wt:foo|1|{{1x|{{#f1_wt:BAR|A|{{1x|B}}|C}}D}}|{{1x|3}}|4}} !! html/parsoid+integrated

foo 1 BAR A B CD 3 4

!! end !! test f1_wt: Case insensitivity !! options parsoid=wt2html,wt2wt !! wikitext {{#F1_wt:x}} {{#f1_WT:y}} !! html/parsoid

x

y

!! end # T391063: the zero-arg form will need to be explicitly permitted as a # "magic variable" in the future. !! test f1_wt_nohash: Test 'nohash' option !! options parsoid=wt2html,wt2wt !! wikitext 0 args: {{f1_wt_nohash}} (no output) 1 arg: {{f1_wt_nohash:foo}} {{#f1_wt_nohash:foo}} !! html/parsoid+standalone

0 args: (no output)

1 arg: foo

Parser function implementation for pf_f1_wt_nohash missing in Parsoid.

!! html/parsoid+integrated

0 args: (no output)

1 arg: foo

{{#f1_wt_nohash:foo}}

!! end !! test f1_wt_hash: Test magic words which already include the leading hash !! options parsoid=wt2html,wt2wt !! wikitext 0 args: {{#f1_wt_hash}} {{f1_wt_hash:foo}} 1 arg: {{#f1_wt_hash:foo}} !! html/parsoid

0 args:

Template:F1 wt hash:foo

1 arg: foo

!! end !! test f2_if: test basic operation !! options parsoid=wt2html,wt2wt !! wikitext {{#f2_if: |yes|NO}} {{#f2_if:{{1x| }}|yes|NO}} {{#f2_if:{{1x|x}}|'''yes'''|NO}} {{#f2_if: |'''YES'''|NO}} {{#f2_if:something|yes|no}} !! html/parsoid

NO

NO

yes

NO

yes

!! end !! test f2_if: Verify lazy evaluation of then/else !! options cat parsoid=wt2html,wt2wt !! wikitext {{#f2_if:1|{{1x|[[Category:Foo]]}}|{{1x|[[Category:Bar]]}}}} !! metadata/parsoid+integrated cat=Foo sort= !! html/parsoid+integrated !! end !! test f3_uc: basic operation !! options parsoid=wt2html,wt2wt !! wikitext {{#f3_uc:lower UPPER}} {{#f3_uc:{{1x|foo}}}} !! html/parsoid

LOWER UPPER

FOO

!! end !! test f3_uc: nowiki content should be skipped (not converted to uppercase) !! options parsoid=wt2html,wt2wt !! wikitext {{#f3_uc:preinsidepost}} !! html/parsoid+integrated

PREinsidePOST

!! end # TODO T390345: content inside should be skipped !! test f3_uc: extension tag content should be skipped (not converted to uppercase) !! options parsoid=wt2html,wt2wt !! wikitext {{#f3_uc:preinsidepost}} !! html/parsoid+integrated

PREinsidePOST

!! end !! test f4_return_html: test returning an HTML fragment !! options parsoid=wt2html,wt2wt !! wikitext {{#f4_return_html}} !! html/parsoid+integrated

html contents

!! end !! test f5_from_nowiki: test retrieving an argument from !! options parsoid=wt2html,wt2wt !! wikitext {{#f5_from_nowiki:argument [[with]] markup '''foo'''}} !! html/parsoid+integrated

'''oof''' >b/<pukram>b< ]]htiw[[ tnemugra

!! end # TODO T390345: argument chaining doesn't work yet # Note also that & is decoded, even inside a ; this isn't # "really" raw text. However, the LiteralPFragment returned by # #f5_from_nowiki *is* really raw text: entities in the returned # value do not get further decoded when they are provided as input. !! test f5_from_nowiki: test chaining literal arguments together !! options parsoid=wt2html,wt2wt disabled !! wikitext {{#f5_from_nowiki:{{#f5_from_nowiki:&amp;}}}} !! html/parsoid+integrated

&amp;

!! end !! test f6_async_return: Test conditionally-asynchronous content (ready case) !! options parsoid=wt2html,wt2wt showflags !! wikitext Content is ready: {{#f6_async_return:ready|Ready!}} !! metadata/parsoid flags=has-async-content !! html/parsoid

Content is ready: Ready!

!! end !! test f6_async_return: Test conditionally-asynchronous content (not ready case) !! options parsoid=wt2html,wt2wt showflags !! wikitext Default fallback content: {{#f6_async_return:not ready}} Specified fallback content: {{#f6_async_return:not ready|My own fallback}} !! metadata/parsoid flags=async-not-ready, has-async-content !! html/parsoid+integrated

Default fallback content:

Specified fallback content: My own fallback

!! end !! test f7_kv: simple return !! options parsoid=wt2html !! wikitext {{#f7_kv:foo=bar|bat=baz}} !! html/parsoid+integrated

(arguments)

!! end # T390345: core doesn't know how to invoke the PFragmentHandler for {{#f7_kv}} !! test f7_kv: ordered argument chaining !! options parsoid=wt2html disabled !! wikitext {{#f1_wt:A|...={{#f7_kv:B|C}}|D}} !! html/parsoid+integrated

A B C D

!! end !! test f8_countargs: verify zero-arg handling !! options parsoid=wt2html !! wikitext * Zero: {{#f8_countargs}} * One: {{#f8_countargs:}} * One: {{#f8_countargs:one}} * Two: {{#f8_countargs:one|two}} !! html/parsoid+integrated
  • Zero: 0
  • One: 1
  • One: 1
  • Two: 2
!! end !! test f8_countargs: verify numeric argument name handling !! options parsoid=wt2html,html2wt !! wikitext * Two: {{#f8_countargs:1=1|2=2}} !! html/parsoid+integrated
  • Two: 2
!! end !! test f8_countargs: handling duplicate arguments (ordered) !! options parsoid=wt2html,html2wt !! wikitext * Six: {{#f8_countargs:1|4|2=2|foo=bar|3|foo=bat}} !! html/parsoid+integrated
  • Six: 6
!! end !! test pfh_countnamedargs: handling duplicate arguments (named) !! options parsoid=wt2html,html2wt !! wikitext * Four: {{#pfh_countnamedargs:1|4|2=2|foo=bar|3|foo=bat}} !! html/parsoid+integrated
  • Four: 4
!! end ## Regression test for T408958 !! test Fostered dom fragment !! wikitext {| [[category:123]]{{#f9_comment}} |test |} !! html/parsoid+integrated
test
!! end ## Regression test for tumwiki !! test Leaking fragment marker !! wikitext {{1x|{}} !! html/parsoid+integrated

{

!! end