Module:Sandbox/Nowiki behavior testing
Jump to navigation
Jump to search
Documentation for Module:Sandbox/Nowiki behavior testing does not exist yet [create] (How does this work?)
local p = {}
function p.whatAreYou(frame)
local before = require("Module:Arguments").getArgs(frame)[1]
mw.log("before: " .. before)
local fixed = mw.text.unstripNoWiki(before)
mw.log("after: " .. fixed)
return fixed
end
function p.logLines(frame)
local input = mw.text.unstripNoWiki(require("Module:Arguments").getArgs(frame)[1])
local lines = mw.text.split(input, "\n")
for _, line in ipairs(lines) do
mw.log("line: <<<" .. line .. ">>>")
mw.log("trimmed: <<<" .. mw.text.trim(line) .. ">>>")
end
end
function p.testRefPreprocessStripMarkerStuff(frame)
local a = frame:preprocess("<ref>This is a ref generated in the Scribunto frame</ref>")
local b = frame:getParent():preprocess("<ref>This is a ref generated in the parent frame</ref>")
local a_in_html = mw.html.create("div"):wikitext(
frame:preprocess("<ref>This is a ref generated in the Scribunto frame and wrapped in a div</ref>")
)
local b_in_html = mw.html.create("div"):wikitext(
frame:getParent():preprocess("<ref>This is a ref generated in the parent frame</ref>")
)
return ([[
===Nowiki output===
==== In scribunto frame ====
%s
==== In parent frame ====
%s
==== From scribunto frame, wrapped ====
%s
==== From parent frame, wrapped ====
%s
]]):format(a, b, tostring(a_in_html), tostring(b_in_html))
end
return p