function util.html_is_safe(str) -- All (ASCII) control characters except \t\n\f\r are forbidden: if string.find(str, "[\0-\8\11\14-\31\127]") then return false, "Invalid ASCII control character" end -- Memorize expected closing tags: local stack = {} -- State during parsing: local para = false --

tag open local bold = false -- tag open local italic = false -- tag open local supsub = false -- or tag open local link = false -- tag open local heading = false -- tag open local list = false --

    or