X-Git-Url: http://nitlanguage.org diff --git a/contrib/nitiwiki/src/wiki_links.nit b/contrib/nitiwiki/src/wiki_links.nit index 03f21ca..ac3e171 100644 --- a/contrib/nitiwiki/src/wiki_links.nit +++ b/contrib/nitiwiki/src/wiki_links.nit @@ -100,12 +100,23 @@ redef class WikiEntry # Relative path to `self` from the target root_url fun href: String do return breadcrumbs.join("/") + # Relative path to the directory `self` from the target root_url + fun dir_href: String do return href.dirname + + # Relative path to the root url from `self` + fun root_href: String do + var root_dir = dir_href.relpath("") + # Avoid issues if used as a macro just followed by a `/` (as with url prefix) + if root_dir == "" then root_dir = "." + return root_dir + end + # A relative `href` to `self` from the page `context`. # # Should be used to navigate between documents. fun href_from(context: WikiEntry): String do - var res = context.href.dirname.relpath(href) + var res = context.dir_href.relpath(href) return res end @@ -174,6 +185,8 @@ redef class WikiSection end return new WikiSectionIndex(wiki, "index", self) end + + redef fun dir_href do return href end redef class WikiArticle @@ -198,7 +211,7 @@ redef class WikiArticle super if not is_dirty and not wiki.force_render or not has_source then return content = md_proc.process(md.as(not null)) - headlines.recover_with(md_proc.emitter.decorator.headlines) + headlines.add_all(md_proc.emitter.decorator.headlines) end end @@ -212,6 +225,8 @@ class WikiSectionIndex redef fun title do return section.title redef fun href do return section.href + + redef fun dir_href do return section.dir_href end # A MarkdownProcessor able to parse wiki links.