2022-08-11 21:20:09 +00:00
!! options
2022-08-26 16:21:46 +00:00
parsoid-compatible
2022-08-11 21:20:09 +00:00
version=2
!! end
2020-04-02 17:20:45 +00:00
# Force the test runner to ensure the extension is loaded
!! functionhooks
invoke
!! endfunctionhooks
2012-05-22 03:56:07 +00:00
!! article
Module:Test
!! text
local p = {}
local isoTestData = ''
2013-02-21 03:41:29 +00:00
local bit = require('bit')
2012-05-22 03:56:07 +00:00
function p.tooFewArgs()
require()
end
function p.getAllArgs( frame )
2012-12-27 22:58:39 +00:00
local buf = {}
local names = {}
local values = {}
for name, value in pairs( frame.args ) do
table.insert(names, name)
values[name] = value
end
table.sort(names, function (a, b) return tostring(a) < tostring(b) end)
for index, name in ipairs(names) do
if #buf ~= 0 then
table.insert( buf, ', ' )
end
table.insert( buf, name .. '=' .. values[name] )
end
return table.concat( buf )
end
function p.getAllArgs2( frame )
2012-05-22 03:56:07 +00:00
local buf = {}
local names = {}
local values = {}
for name, value in frame:argumentPairs() do
table.insert(names, name)
values[name] = value
end
table.sort(names, function (a, b) return tostring(a) < tostring(b) end)
for index, name in ipairs(names) do
if #buf ~= 0 then
table.insert( buf, ', ' )
end
table.insert( buf, name .. '=' .. values[name] )
end
return table.concat( buf )
end
2012-12-27 22:58:39 +00:00
function p.getNumericArgs( frame )
local buf = {}
for index, value in ipairs(frame.args) do
if #buf ~= 0 then
table.insert( buf, ', ' )
end
table.insert( buf, index .. '=' .. value )
end
return table.concat( buf )
end
2012-05-22 03:56:07 +00:00
function p.getArg( frame )
local name = frame.args[1]
return frame:getArgument( name ):expand()
end
function p.getArgLength( frame )
local name = frame.args[1]
return #(frame.args[name])
end
function p.getArgType( frame )
local name = frame.args[1]
return type( frame.args[name] )
end
2014-07-07 18:46:59 +00:00
function p.hello()
2012-05-22 03:56:07 +00:00
return 'hello'
end
function p.emptyTable()
return {}
end
function p.import()
return require('Module:Test2').countBeans()
end
function p.bitop()
return bit.bor(1, bit.bor(2, bit.bor(4, 8)))
end
function p.isolationTestUpvalue( frame )
isoTestData = isoTestData .. frame.args[1]
return isoTestData
end
function p.isolationTestGlobal( frame )
if isoTestDataGlobal == nil then
isoTestDataGlobal = ''
end
isoTestDataGlobal = isoTestDataGlobal .. frame.args[1]
return isoTestDataGlobal
end
function p.getParentArgs( frame )
return p.getAllArgs( frame:getParent() )
end
function p.testExpandTemplate( frame )
return frame:expandTemplate{
title = 'Scribunto_all_args',
args = { x = 1, y = 2, z = '|||' }
}
end
2013-10-10 15:18:13 +00:00
function p.testExpandTemplateWithHeaders( frame )
return frame:expandTemplate{
title = 'Scribunto_template_with_headers'
}
end
2012-05-22 03:56:07 +00:00
function p.testNewTemplateParserValue( frame )
2014-07-07 18:46:59 +00:00
return
2012-05-22 03:56:07 +00:00
frame:newTemplateParserValue{
title = 'Scribunto_all_args',
args = { x = 1, y = 2, z = 'blah' }
} : expand()
end
function p.testPreprocess( frame )
return frame:preprocess( '{{Scribunto_all_args|{{{1}}}}}|x=y' )
end
function p.testNewParserValue( frame )
return frame:newParserValue( '{{Scribunto_all_args|{{{1}}}}}|x=y' ):expand()
end
2012-12-03 06:14:56 +00:00
function p.null( frame )
return '\0'
end
2013-11-01 02:05:00 +00:00
function p.isSubsting( frame )
return tostring( mw.isSubsting() )
end
2013-12-06 18:10:39 +00:00
function p.getFrameTitle( frame )
return frame:getTitle()
end
2014-09-06 19:32:28 +00:00
p['test=InFunctionName'] = function( frame )
return frame.args[1]
end
2014-09-22 02:59:52 +00:00
function p.testStrippedCss( frame )
return mw.html.create( 'div' ):css( 'color', frame.args[1] )
end
2014-05-31 17:42:45 +00:00
function p.testFrameCaching( frame )
return string.format(
'Parent frame is the root: %s. Child frame is the root: %s.',
frame:getParent():preprocess('<includeonly>no</includeonly><noinclude>yes</noinclude>'),
frame:preprocess('<includeonly>no</includeonly><noinclude>yes</noinclude>')
)
end
2012-05-22 03:56:07 +00:00
return p
!! endarticle
!! article
Module:Test2
!! text
return {
countBeans = function ()
return 3
end
}
!! endarticle
2014-05-23 15:43:22 +00:00
!! article
Module:Metatables
!! text
local p, mt1, mt2 = {}, {}, {}
mt1.__index = {}
function p.zero(frame)
return 'You called the zero method from p'
end
function mt1.__index.one(frame)
return 'You called the one method from mt1'
end
function mt2.__index(t, k)
return function(frame)
return 'You called the ' .. k .. ' method from mt2'
end
end
setmetatable(mt1.__index, mt2)
setmetatable(p, mt1)
return p
!! endarticle
2012-05-22 03:56:07 +00:00
!! article
Template:Scribunto_all_args
!! text
{{#invoke:test|getParentArgs}}
!! endarticle
2013-10-10 15:18:13 +00:00
!! article
Template:Scribunto_template_with_headers
!! text
== bar ==
!! endarticle
2014-05-31 17:42:45 +00:00
!! article
Template:Scribunto_frame_caching
!! text
{{#invoke:test|testFrameCaching}}
!! endarticle
2012-05-22 03:56:07 +00:00
!! test
Scribunto: no such module
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"] }
2023-08-07 22:11:46 +00:00
cat
extension=ScribuntoErrors-5e10d413
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:foo|bar}}
2023-08-07 22:11:46 +00:00
!! metadata
cat=Pages_with_script_errors sort=
extension[ScribuntoErrors-5e10d413]="<p>Script error: No such module \"foo\".</p><p>No further details are available.</p>"
2022-08-11 21:20:09 +00:00
!! html/php
2023-08-07 22:11:46 +00:00
<p><strong class="error"><span class="scribunto-error" id="mw-scribunto-error-5e10d413">Script error: No such module "foo".</span></strong>
2012-05-22 03:56:07 +00:00
</p>
2022-08-11 21:20:09 +00:00
!! html/parsoid
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:foo","function":"invoke"},"params":{"1":{"wt":"bar"}},"i":0}}]}'><span class="scribunto-error" id="mw-scribunto-error-0">Script error: No such module <span typeof="mw:Entity">"</span>foo<span typeof="mw:Entity">"</span>.</span></strong></p>
2012-05-22 03:56:07 +00:00
!! end
!! test
Scribunto: no such function
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"] }
2023-08-07 22:11:46 +00:00
cat
extension=ScribuntoErrors-d64a22ba
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|blah}}
2023-08-07 22:11:46 +00:00
!! metadata
cat=Pages_with_script_errors sort=
extension[ScribuntoErrors-d64a22ba]="<p>Script error: The function \"blah\" does not exist.</p><p>No further details are available.</p>"
2022-08-11 21:20:09 +00:00
!! html/php
2023-08-07 22:11:46 +00:00
<p><strong class="error"><span class="scribunto-error" id="mw-scribunto-error-d64a22ba">Script error: The function "blah" does not exist.</span></strong>
2012-05-22 03:56:07 +00:00
</p>
2022-08-11 21:20:09 +00:00
!! html/parsoid
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"blah"}},"i":0}}]}'><span class="scribunto-error" id="mw-scribunto-error-0">Script error: The function <span typeof="mw:Entity">"</span>blah<span typeof="mw:Entity">"</span> does not exist.</span></strong></p>
2012-05-22 03:56:07 +00:00
!! end
!! test
Scribunto: hello world
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|hello}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>hello
</p>
!! end
!! test
Scribunto: getAllArgs
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-12-27 22:58:39 +00:00
{{#invoke:test|getAllArgs|x|y|z|a=1|b=2|c=3|7=?}}
2020-04-02 17:20:45 +00:00
!! html
2012-12-27 22:58:39 +00:00
<p>1=x, 2=y, 3=z, 7=?, a=1, b=2, c=3
</p>
!! end
!! test
Scribunto: getAllArgs, deprecated style
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-12-27 22:58:39 +00:00
{{#invoke:test|getAllArgs2|x|y|z|a=1|b=2|c=3|7=?}}
2020-04-02 17:20:45 +00:00
!! html
2012-12-27 22:58:39 +00:00
<p>1=x, 2=y, 3=z, 7=?, a=1, b=2, c=3
</p>
!! end
!! test
Scribunto: getNumericArgs
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-12-27 22:58:39 +00:00
{{#invoke:test|getNumericArgs|x|y|z|a=1|b=2|c=3|7=?}}
2020-04-02 17:20:45 +00:00
!! html
2012-12-27 22:58:39 +00:00
<p>1=x, 2=y, 3=z
2012-05-22 03:56:07 +00:00
</p>
!! end
!! test
Scribunto: named numeric parameters
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"] }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|getArg|2|a|2=b}}
{{#invoke:test|getArg|2|2=a|b}}
2022-08-11 21:20:09 +00:00
!! html/php
2012-05-22 03:56:07 +00:00
<p>b
b
</p>
2022-08-11 21:20:09 +00:00
!! html/parsoid
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArg"},"2":{"wt":"b"},"3":{"wt":"a"}},"i":0}}]}'>b</span>
<span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArg"},"2":{"wt":"a"},"3":{"wt":"b"}},"i":0}}]}'>b</span></p>
2012-05-22 03:56:07 +00:00
!! end
!! test
Scribunto: template-style argument trimming
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"] }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|getArgLength|2| x }}
{{#invoke:test|getArgLength|2|2= x }}
2022-08-11 21:20:09 +00:00
!! html/php
2012-05-22 03:56:07 +00:00
<p>3
1
</p>
2022-08-11 21:20:09 +00:00
!! html/parsoid
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArgLength"},"2":{"wt":"2"},"3":{"wt":" x "}},"i":0}}]}'>3</span>
<span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArgLength"},"2":{"wt":"x"}},"i":0}}]}'>1</span></p>
2012-05-22 03:56:07 +00:00
!! end
!! test
Scribunto: missing argument
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|getArgType|2}}
{{#invoke:test|getArgType|blah}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>nil
nil
</p>
!! end
!! test
Scribunto: parent frame access
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{Scribunto_all_args|x|y|z|a = 1|b = 2|c = 3}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>1=x, 2=y, 3=z, a=1, b=2, c=3
</p>
!! end
!! test
Scribunto: expandTemplate
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|testExpandTemplate}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>x=1, y=2, z=|||
</p>
!! end
2013-10-10 15:18:13 +00:00
!! test
Scribunto: expandTemplate with headers
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2013-10-10 15:18:13 +00:00
==foo==
{{#invoke:test|testExpandTemplateWithHeaders}}
2020-04-02 17:20:45 +00:00
!! html
2015-03-18 14:42:57 +00:00
<h2><span class="mw-headline" id="foo">foo</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: foo">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2022-05-14 00:44:13 +00:00
<h2><span class="mw-headline" id="bar">bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Scribunto_template_with_headers&action=edit&section=T-1" title="Edit section: bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2013-10-10 15:18:13 +00:00
!! end
2012-05-22 03:56:07 +00:00
!! test
Scribunto: newTemplateParserValue
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|testNewTemplateParserValue}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>x=1, y=2, z=blah
</p>
!! end
!! test
Scribunto: preprocess
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|testPreprocess|foo}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>1=foo|x=y
</p>
!! end
!! test
Scribunto: newParserValue
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|testNewParserValue|foo}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>1=foo|x=y
</p>
!! end
!! test
Scribunto: table return
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|emptyTable}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>table
</p>
!! end
!! test
Scribunto: require
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|import}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>3
</p>
!! end
!! test
Scribunto: access to a module imported at the chunk level
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|bitop}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>15
</p>
!! end
!! test
Scribunto: invoke instance upvalue isolation
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|isolationTestUpvalue|1}}
{{#invoke:test|isolationTestUpvalue|2}}
{{#invoke:test|isolationTestUpvalue|3}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>1
2
3
</p>
!! end
!! test
Scribunto: invoke instance global isolation
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-05-22 03:56:07 +00:00
{{#invoke:test|isolationTestGlobal|1}}
{{#invoke:test|isolationTestGlobal|2}}
{{#invoke:test|isolationTestGlobal|3}}
2020-04-02 17:20:45 +00:00
!! html
2012-05-22 03:56:07 +00:00
<p>1
2
3
</p>
!! end
2012-12-03 06:14:56 +00:00
!! test
Scribunto: ASCII null
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2012-12-03 06:14:56 +00:00
{{#invoke:test|null}}
2020-04-02 17:20:45 +00:00
!! html
2012-12-03 06:14:56 +00:00
<p><3E>
</p>
!! end
2013-11-01 02:05:00 +00:00
!! test
Scribunto: isSubsting during PST
!! options
pst
2022-08-11 21:20:09 +00:00
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2013-11-01 02:05:00 +00:00
{{safesubst:#invoke:test|isSubsting}}
2020-04-02 17:20:45 +00:00
!! html
2013-11-01 02:05:00 +00:00
true
!! end
!! test
Scribunto: isSubsting during normal parse
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2013-11-01 02:05:00 +00:00
{{safesubst:#invoke:test|isSubsting}}
2020-04-02 17:20:45 +00:00
!! html
2013-11-01 02:05:00 +00:00
<p>false
</p>
!! end
2013-12-06 18:10:39 +00:00
!! test
Scribunto: frame:getTitle
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2013-12-06 18:10:39 +00:00
{{#invoke:test|getFrameTitle}}
2020-04-02 17:20:45 +00:00
!! html
2013-12-06 18:10:39 +00:00
<p>Module:Test
</p>
!! end
2014-05-23 15:43:22 +00:00
!! test
Scribunto: Metatable on export table
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2014-05-23 15:43:22 +00:00
{{#invoke:Metatables|zero}}
{{#invoke:Metatables|one}}
{{#invoke:Metatables|two}}
2020-04-02 17:20:45 +00:00
!! html
2014-05-23 15:43:22 +00:00
<p>You called the zero method from p
You called the one method from mt1
You called the two method from mt2
</p>
!! end
2014-09-06 19:32:28 +00:00
!! test
Scribunto: Correct argument numbering with equals sign in function name
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2014-09-06 19:32:28 +00:00
{{#invoke:test|test=InFunctionName|good|bad}}
2020-04-02 17:20:45 +00:00
!! html
2014-09-06 19:32:28 +00:00
<p>good
</p>
!! end
2014-09-22 02:59:52 +00:00
!! test
Scribunto: Strip markers in CSS
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2014-09-22 02:59:52 +00:00
{{#invoke:test|testStrippedCss|<nowiki>#ff0000</nowiki>}}
2020-04-02 17:20:45 +00:00
!! html
2014-09-22 02:59:52 +00:00
<div style="color:#ff0000"></div>
!! end
2014-05-31 17:42:45 +00:00
!! test
Scribunto: Parser output isn't incorrectly cached across frames
2022-08-11 21:20:09 +00:00
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
2020-04-02 17:20:45 +00:00
!! wikitext
2014-05-31 17:42:45 +00:00
Root: {{#invoke:test|testFrameCaching}} Template: {{Scribunto frame caching}}
2020-04-02 17:20:45 +00:00
!! html
2014-05-31 17:42:45 +00:00
<p>Root: Parent frame is the root: yes. Child frame is the root: no. Template: Parent frame is the root: no. Child frame is the root: no.
</p>
!! end
2022-08-11 21:20:09 +00:00
# Tests for T272507
!! article
Module:EchoTest
!! text
local p = {}
function p.echo(frame)
return frame.args[1]
end
return p
!! end
!! article
Module:UnstripTest
!! text
local p = {}
function p.unstrip(frame)
return mw.text.nowiki(mw.text.unstripNoWiki(frame.args[1]))
end
return p
!! end
!! test
Scribunto: Test unstripNowiki behavior
!! options
parsoid={ "modes": ["wt2html","wt2wt"] }
!! wikitext
{{#invoke:EchoTest|echo|<nowiki>foo</nowiki>}}
{{#invoke:EchoTest|echo|<nowiki>[[Foo]]</nowiki>}}
{{#invoke:UnstripTest|unstrip|<nowiki>foo</nowiki>}}
{{#invoke:UnstripTest|unstrip|<nowiki>[[Foo]]</nowiki>}}
!! html/php
<p>foo
[[Foo]]
</p><p>foo
[[Foo]]
</p>
!! html/parsoid
<p><span typeof="mw:Nowiki mw:Transclusion" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:EchoTest","function":"invoke"},"params":{"1":{"wt":"echo"},"2":{"wt":"<nowiki>foo</nowiki>"}},"i":0}}]}'>foo</span>
<span typeof="mw:Nowiki mw:Transclusion" about="#mwt6" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:EchoTest","function":"invoke"},"params":{"1":{"wt":"echo"},"2":{"wt":"<nowiki>[[Foo]]</nowiki>"}},"i":0}}]}'>[[Foo]]</span></p>
<p><span about="#mwt10" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:UnstripTest","function":"invoke"},"params":{"1":{"wt":"unstrip"},"2":{"wt":"<nowiki>foo</nowiki>"}},"i":0}}]}'>foo</span>
<span typeof="mw:Transclusion mw:Entity" about="#mwt12" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:UnstripTest","function":"invoke"},"params":{"1":{"wt":"unstrip"},"2":{"wt":"<nowiki>[[Foo]]</nowiki>"}},"i":0}}]}'>[</span><span typeof="mw:Entity" about="#mwt12">[</span><span about="#mwt12">Foo</span><span typeof="mw:Entity" about="#mwt12">]</span><span typeof="mw:Entity" about="#mwt12">]</span></p>
!! end