Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
317:c730ff1e4bae | 318:4fe6c9fed486 |
---|---|
1 java() | 1 java() |
2 import "java:luan.modules.HtmlLuan" | 2 import "java:luan.modules.HtmlLuan" |
3 | 3 |
4 encode = HtmlLuan.encode | 4 encode = HtmlLuan.encode |
5 parse = HtmlLuan.parse | |
6 _ENV.to_string = HtmlLuan.to_string | |
7 | |
8 | |
9 | |
10 -- extras | |
11 | |
12 function process_url_tags(html) | |
13 for i, v in ipairs(html) do | |
14 if type(v) == "table" and v.type == "tag" then | |
15 if v.name == "url" then | |
16 local url = v.attributes.url or html[i+1] | |
17 v.name = "a" | |
18 v.attributes.url = nil | |
19 v.attributes.href = url | |
20 elseif v.name == "/url" then | |
21 v.name = "/a" | |
22 end | |
23 end | |
24 end | |
25 end | |
26 | |
27 function add_nofollow(html) | |
28 for i, v in ipairs(html) do | |
29 if type(v) == "table" and v.type == "tag" then | |
30 if v.name == "a" then | |
31 v.attributes.rel = "nofollow" | |
32 end | |
33 end | |
34 end | |
35 end |