Module:Sandbox/Lemondoge/prevaluate
Appearance
local p = {}
function p.main(frame)
-- Undo sanitization:
local wikitext = frame.args[1] or ''
if wikitext:match'nowiki' then
wikitext = mw.text.unstripNoWiki(wikitext):gsub('<', '<'):gsub('>', '>')
else error("<nowiki> missing from first parameter") end
local argRestOnly = (require('Module:Yesno')(frame.args[2] or 'yes') and "ArgRest|main|" or ".+")
local function doProcessing(str)
return (str:match("#invoke:" .. argRestOnly) and frame:preprocess("{{" .. str .. "}}") or str)
end
return frame:preprocess(wikitext:gsub("%{(%b{})%}", function (a) return doProcessing(a:sub(1, -2)) end))
end
return p