markdown :: TokenEntity :: check_entity
# Is the entity valid?
private fun check_entity(out: FlatBuffer, md: Text, start: Int): Int do
var pos = md.read_until(out, start, ';')
if pos < 0 or out.length < 3 then
return -1
end
if out[1] == '#' then
if out[2] == 'x' or out[2] == 'X' then
if out.length < 4 then return -1
for i in [3..out.length[ do
var c = out[i]
if (c < '0' or c > '9') and (c < 'a' and c > 'f') and (c < 'A' and c > 'F') then
return -1
end
end
else
for i in [2..out.length[ do
var c = out[i]
if c < '0' or c > '9' then return -1
end
end
out.add ';'
else
for i in [1..out.length[ do
var c = out[i]
if not c.is_digit and not c.is_letter then return -1
end
out.add ';'
# TODO check entity is valid
# if out.is_entity then
return pos
# else
# return -1
# end
end
return pos
end
lib/markdown/markdown.nit:2265,2--2301,4