view core/src/luan/modules/Html.luan @ 321:7f7708e8fdd4

remove import statement git-svn-id: https://luan-java.googlecode.com/svn/trunk@322 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 08 Feb 2015 07:26:20 +0000
parents fed1893821bf
children b24a35612947
line wrap: on
line source

java()
local HtmlLuan = require "java:luan.modules.HtmlLuan"

encode = HtmlLuan.encode
parse = HtmlLuan.parse
to_string = HtmlLuan.to_string



-- extras

local Luan = require "luan:Luan"
local ipairs = Luan.ipairs
local type = Luan.type

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