Property definitions

markdown $ TokenHTML :: defaultinit
# A HTML/XML token.
class TokenHTML
	super Token

	redef fun emit(v) do
		var tmp = new FlatBuffer
		var b = check_html(v, tmp, v.current_text.as(not null), v.current_pos)
		if b > 0 then
			v.add tmp
			v.current_pos = b
		else
			v.decorator.escape_char(v, char)
		end
	end

	# Is the HTML valid?
	# Also take care of link and mailto shortcuts.
	private fun check_html(v: MarkdownProcessor, out: FlatBuffer, md: Text, start: Int): Int do
		# check for auto links
		var tmp = new FlatBuffer
		var pos = md.read_until(tmp, start + 1, ':', ' ', '>', '\n')
		if pos != -1 and md[pos] == ':' and tmp.is_link_prefix then
			pos = md.read_until(tmp, pos, '>')
			if pos != -1 then
				var link = tmp.write_to_string
				v.decorator.add_link(v, link, link, null)
				return pos
			end
		end
		# TODO check for mailto
		# check for inline html
		if start + 2 < md.length then
			return md.read_xml(out, start, true)
		end
		return -1
	end
end
lib/markdown/markdown.nit:2212,1--2248,3