Module:Sandbox/Lemondoge/prevaluate

local p = {}

-- TODO: It SEEMS like recurseInner is successfully preprocessing argRest. The one problem is that argRest is seeing this function as its parent, which means it receives the whole block of wikitext preValuate is given. function p.main(frame) -- Undo sanitization: local wikitext = frame.args[1] or '' if wikitext:match'nowiki' then wikitext = mw.text.unstripNoWiki(wikitext):gsub('&lt;', '<'):gsub('&gt;', '>') else error(" missing from first parameter") end local argRestOnly = (require('Module:Yesno')(frame.args[2] or 'no') and "ArgRest|main|.+" or ".+") local salt = "!! SALT: " local function recurseInner(input) -- Dive through local str = input:sub(3, -3) if input:find("^{{#invoke:" .. argRestOnly) then salt = salt .. frame:preprocess(input) return frame:preprocess(input) elseif str:match("#invoke:" .. argRestOnly) then return str:gsub("%{%b{}%}", recurseInner) .. "!! thing   " .. input .. "  thingend" else return input end end local function doProcessing(str) str = str:sub(3, -3) local testity local j = str:gsub("%{%b{}%}", recurseInner):match("#invoke:" .. argRestOnly) --if true then			salt = salt .. "!!  Salt2: " .. str:gsub("%{%b{}%}", recurseInner)			--return "{{" .. frame:preprocess(str:gsub("%{%b{}%}", recurseInner)) .. "}}"		end-- return (j and frame:preprocess("{{" .. j .. "}}") or "{{" .. str .. "}}") end if false then return wikitext:gsub("%{%b{}%}", doProcessing) .. salt --return wikitext:gsub("%{%b{}%}", doProcessing) end return frame:preprocess(wikitext:gsub("%{%b{}%}", doProcessing)) .. salt end

return p