From Wikipedia, the free encyclopedia


local p = {}



function p.main(frame)

	-- Undo sanitization:

	local code = frame.args1 or ''

	if code:match'nowiki' then

		code = mw.text.unstripNoWiki(code)

	else error("<nowiki> missing from first parameter") end

	

	-- Angle brackets still remain santiized; unsanitize them

	local wikitext = code:gsub('&lt;', '<'):gsub('&gt;', '>')

	

	local secondParam = frame.args2

    local start = tonumber(secondParam:match('%d+')) -- Extract the first number from the second parameter

    local result = ''

    

    assert(secondParam, "second parameter missing")

    

    local function replaceTripleBraces(parameter, _, default, i) -- extract corresponding arguments from the parent function. the _ is necessary because the pipe still gets caught in the second capture group

    	if _ == "" then default = nil end -- mildly ugly hack for checking for {{{parameter|}}}

		return frame:getParent().argsparameter:gsub("%d+", tostring(i))] or default or "{{{" .. parameter .. "}}}"

    end 

    

    for i = start, math.huge do

        -- Check if the parameter is defined

        if not frame:getParent().argssecondParam:gsub('%d+', tostring(i))] then 

        	break

        end



        local processed = wikitext:gsub("{{{([^{}<>|]+)(|?)([^{}|]*)}}}", function(a, b, c) return replaceTripleBraces(a, b, c, i) end) -- Find stuff of the form {{{parameter}}} or {{{parameter|default}}} via pattern matching

        result = result .. processed

    end

    

    return frame:preprocess(result)

end



return p
From Wikipedia, the free encyclopedia


local p = {}



function p.main(frame)

	-- Undo sanitization:

	local code = frame.args1 or ''

	if code:match'nowiki' then

		code = mw.text.unstripNoWiki(code)

	else error("<nowiki> missing from first parameter") end

	

	-- Angle brackets still remain santiized; unsanitize them

	local wikitext = code:gsub('&lt;', '<'):gsub('&gt;', '>')

	

	local secondParam = frame.args2

    local start = tonumber(secondParam:match('%d+')) -- Extract the first number from the second parameter

    local result = ''

    

    assert(secondParam, "second parameter missing")

    

    local function replaceTripleBraces(parameter, _, default, i) -- extract corresponding arguments from the parent function. the _ is necessary because the pipe still gets caught in the second capture group

    	if _ == "" then default = nil end -- mildly ugly hack for checking for {{{parameter|}}}

		return frame:getParent().argsparameter:gsub("%d+", tostring(i))] or default or "{{{" .. parameter .. "}}}"

    end 

    

    for i = start, math.huge do

        -- Check if the parameter is defined

        if not frame:getParent().argssecondParam:gsub('%d+', tostring(i))] then 

        	break

        end



        local processed = wikitext:gsub("{{{([^{}<>|]+)(|?)([^{}|]*)}}}", function(a, b, c) return replaceTripleBraces(a, b, c, i) end) -- Find stuff of the form {{{parameter}}} or {{{parameter|default}}} via pattern matching

        result = result .. processed

    end

    

    return frame:preprocess(result)

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook