# 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 cat=Foo sort= !! html/parsoid !! 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 # TODO T390344: named arguments (add back wt2wt mode once fixed) # TODO T390347: argument interpolation !! test f7_kv: ordered argument chaining !! options parsoid=wt2html !! 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 # Disabled because named arguments aren't yet supported !! test f8_countargs: verify numeric argument name handling !! options parsoid=wt2html disabled !! wikitext * Two: {{#f8_countargs:1=1|2=2}} !! html/parsoid+integrated !! end