All pastes #516415 Raw Edit

Someone

public lua v1 · immutable
#516415 ·published 2007-05-28 17:55 UTC
rendered paste body
local function xml_escape(string)    return stringendlocal function process_tag(table, key, args)    local middle, k, v, b = ""        args.n = nil    if type(args[2]) == "table" then        for k, v in ipairs(args[2]) do            middle = middle .. v        end    elseif type(args[2] == "string") then        middle = xml_escape(args[2])    end        if middle ~= "" then        return "<" .. key .. ">" .. middle .. "</" .. key .. ">"    else        return "<" .. key .. "/>"    endendlocal xmlmarkup_metatable = {    __index = function(table, key)        local t, k = table, key        return function(...) return process_tag(t, k, arg) end    end}function NewXmlMarkup()    local r = {            }        setmetatable(r, xmlmarkup_metatable)        return rendxm = NewXmlMarkup()s = xm:html {    xm:head {        xm:title "Test"    },    xm:body {        xm:b "Bold test."    }}print(s)