markdown :: TokenEntity :: defaultinit
markdown $ TokenEntity :: SELF
Type of this instance, automatically specialized in every classmarkdown $ TokenEntity :: emit
Output that token usingMarkdownEmitter::decorator
.
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
markdown :: Token :: defaultinit
markdown :: TokenEntity :: defaultinit
core :: Object :: defaultinit
MarkdownEmitter::decorator
.
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
self
in the original input.
markdown :: Token :: location=
Location ofself
in the original input.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# An HTML entity token.
class TokenEntity
super Token
redef fun emit(v) do
var tmp = new FlatBuffer
var b = check_entity(tmp, v.current_text.as(not null), pos)
if b > 0 then
v.add tmp
v.current_pos = b
else
v.decorator.escape_char(v, char)
end
end
# 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
end
lib/markdown/markdown.nit:2250,1--2302,3