24,538 ARTICLES
ON THIS WIKI

Module:Navbox2

Documentation for this module may be created at Module:Navbox2/doc

local p = {}

-- This function converts a string into a table
local function unserialize(s)
	-- Replace the delimiter
	s = s:gsub("<","{")
	s = s:gsub(">","}")
	s = s:gsub("|",",")

	-- Add quotes
	s = s:gsub('=([^=#<>%[%]|{}]+)%s*([},])', '="%1"%2')
	s = s:gsub( '([{,])%s*([^"=,#<>%[%]|{}]+)%s*([},])', '%1"%2"%3')
	-- Need to repeat as the pattern overlaps for adjacent ones
	s = s:gsub( '([{,])%s*([^"=,#<>%[%]|{}]+)%s*([},])', '%1"%2"%3')
	
	local gentables = loadstring('return ' .. s)
	return gentables()
end

-- Creates a navbox
function p.navbox(frame)
	local content = frame.args.content or ""
	
	local t = unserialize(content)
end

return p