Jump to content

Module:Automarkup

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Petr Matas (talk | contribs) at 16:12, 14 December 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	
	local templateArgs = { }
	for key, value in pairs(args) do
		if type(key) == "number" then
			templateArgs[2 * key - 1] = value
			local newVal, count = value:gsub("^<nowiki>", "")
			if count == 1 then newVal = newVal:gsub("</nowiki>$", "") end
			templateArgs[2 * key] = value:len()
		else
			templateArgs[key] = value
		end
	end
	
	return frame:expandTemplate{ title = "Markup", args = templateArgs }
end

return p