--Characters to escape in the body text local escapes = { ["&"] = "&", ["<"] = "<", [">"] = ">", ['"'] = """, ["'"] = "'", --Kinda hacky ["\n"] = "
", } local esctbl = {} for char,_ in pairs(escapes) do table.insert(esctbl,char) end local escapematch = string.format("([%s])",table.concat(esctbl)) local function sanitize(capture) return escapes[capture] or capture end return function(text) return string.gsub(text,escapematch,sanitize) end