Merge: doc: fixed some typos and other misc. corrections
[nit.git] / lib / markdown / wikilinks.nit
index 22b67c0..ea174c2 100644 (file)
@@ -41,11 +41,11 @@ 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: PROCESSOR, token: TokenWikiLink) do
+               if token.name != null then
+                       v.add "[[{token.name.as(not null).to_s}|{token.link.as(not null).to_s}]]"
                else
-                       v.add "[[{link}]]"
+                       v.add "[[{token.link.as(not null).to_s}]]"
                end
        end
 end
@@ -67,11 +67,12 @@ class TokenWikiLink
        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
                var md = v.current_text
+               if md == null then return -1
                var pos = start + 2
                var tmp = new FlatBuffer
                pos = md.read_md_link_id(tmp, pos)
@@ -88,7 +89,6 @@ class TokenWikiLink
                pos += 1
                pos = md.skip_spaces(pos)
                if pos < start then return -1
-               pos += 1
                return pos
        end
 end