Mercurial Hosting > luan
diff src/luan/modules/Html.luan @ 1712:36c28be6d432
improve html and bbcode
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Jul 2022 22:14:21 -0600 |
parents | af45ed10aff6 |
children | f8eba0442956 |
line wrap: on
line diff
--- a/src/luan/modules/Html.luan Wed Jul 13 21:50:41 2022 -0600 +++ b/src/luan/modules/Html.luan Thu Jul 14 22:14:21 2022 -0600 @@ -1,6 +1,5 @@ require "java" local HtmlLuan = require "java:luan.modules.HtmlLuan" -local HtmlParser = require "java:luan.modules.parsers.Html" local URLEncoder = require "java:java.net.URLEncoder" local URLDecoder = require "java:java.net.URLDecoder" local JsonToString = require "java:goodjava.json.JsonToString" @@ -16,16 +15,14 @@ local Html = {} Html.decode = HtmlLuan.decode -Html.encode = HtmlLuan.encode +local encode = HtmlLuan.encode +Html.encode = encode Html.javascript_encode = JsonToString.javascriptEncode -local quote = HtmlLuan.quote -Html.quote = quote - function Html.parse(text,container_tags) text or error "text required" container_tags = container_tags or {"script","style","textarea"} - return HtmlParser.toList(text,container_tags) + return HtmlLuan.parse(text,container_tags) end function Html.url_encode(s) @@ -41,7 +38,7 @@ for name, value in pairs(tag.attributes) do %> <%= name %><% if value ~= true then - %>=<%= quote(value) %><% + %>="<%= encode(value) %>"<% end end if tag.is_empty then @@ -55,7 +52,7 @@ for _, obj in ipairs(list) do local tp = type(obj) if tp == "string" then - %><%= obj %><% + %><%= encode(obj) %><% elseif tp == "table" then tp = obj.type if tp == nil then