Module:Transform infobox declarations

local exports = {};

function exports.main(frame) local out = ""; local current = frame.args[1]; local depth = 0; local argument = false; local open; local close; while current:find("{{") do       if depth < 0 then return frame:expandTemplate({title="error", {error}}); end open, _ = current:find("{{"); close, _ = current:find("}}"); if open < close then if argument then return frame:expandTemplate({title="error", {error}}); end if current:sub(3, 3) == "{" and current:sub(4, 4) ~= "{" then current = current:sub(4); argument = true; else current = current:sub(3); depth = depth + 1; end else if argument then if current:sub(3, 3) ~= "}" then return frame:expandTemplate({title="error", {error}}); end current = current:sub(4); argument = false; else current = current:sub(3); depth = depth - 1; end end end end