Mercurial Hosting > luan
diff core/src/luan/modules/Html.luan @ 318:4fe6c9fed486
add html processing
git-svn-id: https://luan-java.googlecode.com/svn/trunk@319 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 05 Feb 2015 03:28:23 +0000 |
parents | 2f8938fc518c |
children | fed1893821bf |
line wrap: on
line diff
--- a/core/src/luan/modules/Html.luan Tue Dec 30 15:33:46 2014 +0000 +++ b/core/src/luan/modules/Html.luan Thu Feb 05 03:28:23 2015 +0000 @@ -2,3 +2,34 @@ import "java:luan.modules.HtmlLuan" encode = HtmlLuan.encode +parse = HtmlLuan.parse +_ENV.to_string = HtmlLuan.to_string + + + +-- extras + +function process_url_tags(html) + for i, v in ipairs(html) do + if type(v) == "table" and v.type == "tag" then + if v.name == "url" then + local url = v.attributes.url or html[i+1] + v.name = "a" + v.attributes.url = nil + v.attributes.href = url + elseif v.name == "/url" then + v.name = "/a" + end + end + end +end + +function add_nofollow(html) + for i, v in ipairs(html) do + if type(v) == "table" and v.type == "tag" then + if v.name == "a" then + v.attributes.rel = "nofollow" + end + end + end +end