if not token isa TokenLink then return token
if pos + 1 < text.length then
var c = text[pos + 1]
- if c == '[' then return new TokenWikiLink(pos, c)
+ if c == '[' then return new TokenWikiLink(token.location, pos, c)
end
return token
end
redef class Decorator
# Renders a `[[wikilink]]` item.
- fun add_wikilink(v: EMITTER, link: Text, name, comment: nullable Text) do
- if name != null then
- v.add "[[{name}|{link}]]"
+ fun add_wikilink(v: EMITTER, token: TokenWikiLink) do
+ if token.name != null then
+ v.add "[[{token.name.to_s}|{token.link.to_s}]]"
else
- v.add "[[{link}]]"
+ v.add "[[{token.link.to_s}]]"
end
end
end
super TokenLink
redef fun emit_hyper(v) do
- v.decorator.add_wikilink(v, link.as(not null), name, comment)
+ v.decorator.add_wikilink(v, self)
end
redef fun check_link(v, out, start, token) do
pos += 1
pos = md.skip_spaces(pos)
if pos < start then return -1
- pos += 1
return pos
end
end