nitiwiki: make all wiki entries able to parse markdown
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 2 Jun 2015 04:46:42 +0000 (00:46 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 10 Jun 2015 00:39:03 +0000 (20:39 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

contrib/nitiwiki/src/wiki_links.nit

index b542ff2..5235699 100644 (file)
@@ -118,6 +118,10 @@ redef class WikiEntry
                end
                return null
        end
+
+       private var md_proc: NitiwikiMdProcessor is lazy do
+               return new NitiwikiMdProcessor(wiki, self)
+       end
 end
 
 redef class WikiSection
@@ -155,7 +159,6 @@ redef class WikiArticle
        redef fun render do
                super
                if not is_dirty and not wiki.force_render or not has_source then return
-               var md_proc = new NitiwikiMdProcessor(wiki, self)
                content = md_proc.process(md.as(not null))
                headlines.recover_with(md_proc.emitter.decorator.headlines)
        end
@@ -183,7 +186,7 @@ class NitiwikiMdProcessor
        # Article parsed by `self`.
        #
        # Used to contextualize links.
-       var context: WikiArticle
+       var context: WikiEntry
 
        init do
                emitter = new MarkdownEmitter(self)
@@ -198,7 +201,7 @@ private class NitiwikiDecorator
        var wiki: Nitiwiki
 
        # Article used to contextualize links.
-       var context: WikiArticle
+       var context: WikiEntry
 
        redef fun add_wikilink(v, link, name, comment) do
                var wiki = v.processor.as(NitiwikiMdProcessor).wiki
@@ -222,7 +225,8 @@ private class NitiwikiDecorator
                        if name == null then name = target.title
                        link = target.url
                else
-                       wiki.message("Warning: unknown wikilink `{link}` (in {context.src_path.as(not null)})", 0)
+                       var loc = context.src_path or else context.name
+                       wiki.message("Warning: unknown wikilink `{link}` (in {loc})", 0)
                        v.add "class=\"broken\" "
                end
                v.add "href=\""