2020-05-16 01:10:11 +02:00
|
|
|
--Characters to escape in the body text
|
|
|
|
local escapes = {
|
|
|
|
["&"] = "&",
|
|
|
|
["<"] = "<",
|
|
|
|
[">"] = ">",
|
|
|
|
['"'] = """,
|
|
|
|
["'"] = "'",
|
|
|
|
--Kinda hacky
|
2020-12-24 05:36:52 +01:00
|
|
|
["\n"] = "<br/>",
|
2020-05-16 01:10:11 +02:00
|
|
|
}
|
|
|
|
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)
|
2020-05-20 02:13:30 +02:00
|
|
|
text = string.gsub(text,escapematch,sanitize)
|
|
|
|
--text = string.gsub(text,"\n\n","<p>")
|
|
|
|
return text
|
2020-05-16 01:10:11 +02:00
|
|
|
end
|