+ # 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.dir_href.relpath(href)
+ return res
+ end
+
+ # A relative hyperlink <a> to `self` from the page `context`.
+ #
+ # If `text` is not given, `title` will be used instead.
+ fun a_from(context: WikiEntry, text: nullable Text): Writable
+ do
+ var title = title.html_escape
+ if text == null then text = title else text = text.html_escape
+ var href = href_from(context)
+ return """<a href="{{{href}}}" title="{{{title}}}">{{{text}}}</a>"""
+ end