From a67bfae42fb92caf0e7e5609b20ad9e2b40ed459 Mon Sep 17 00:00:00 2001 From: Frans Bouma Date: Mon, 7 Mar 2016 11:10:48 +0100 Subject: [PATCH] Fixes #30 --- src/DocNet/SimpleNavigationElement.cs | 4 ++-- src/DocNet/Utils.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/DocNet/SimpleNavigationElement.cs b/src/DocNet/SimpleNavigationElement.cs index decc4ff..9fee609 100644 --- a/src/DocNet/SimpleNavigationElement.cs +++ b/src/DocNet/SimpleNavigationElement.cs @@ -62,6 +62,7 @@ namespace Docnet var sb = new StringBuilder(activeConfig.PageTemplateContents.Length + 2048); var content = string.Empty; this.MarkdownFromFile = string.Empty; + var relativePathToRoot = Utils.MakeRelativePathForUri(Path.GetDirectoryName(destinationFile), activeConfig.Destination); if(File.Exists(sourceFile)) { this.MarkdownFromFile = File.ReadAllText(sourceFile); @@ -84,7 +85,7 @@ namespace Docnet { continue; } - defaultMarkdown.AppendFormat("* [{0}]({1}){2}", sibling.Name, HttpUtility.UrlPathEncode(sibling.TargetURL), Environment.NewLine); + defaultMarkdown.AppendFormat("* [{0}]({1}{2}){3}", sibling.Name, relativePathToRoot, HttpUtility.UrlPathEncode(sibling.TargetURL), Environment.NewLine); } defaultMarkdown.Append(Environment.NewLine); content = Utils.ConvertMarkdownToHtml(defaultMarkdown.ToString(), Path.GetDirectoryName(destinationFile), activeConfig.Destination, _relativeH2LinksOnPage); @@ -103,7 +104,6 @@ namespace Docnet sb.Replace("{{Name}}", activeConfig.Name); sb.Replace("{{Footer}}", activeConfig.Footer); sb.Replace("{{TopicTitle}}", this.Name); - var relativePathToRoot = Utils.MakeRelativePath(Path.GetDirectoryName(destinationFile), activeConfig.Destination).Replace(@"\", @"/"); sb.Replace("{{Path}}", relativePathToRoot); sb.Replace("{{Breadcrumbs}}", activePath.CreateBreadCrumbsHTML(relativePathToRoot)); sb.Replace("{{ToC}}", activePath.CreateToCHTML(relativePathToRoot)); diff --git a/src/DocNet/Utils.cs b/src/DocNet/Utils.cs index 492f128..243c830 100644 --- a/src/DocNet/Utils.cs +++ b/src/DocNet/Utils.cs @@ -184,5 +184,18 @@ namespace Docnet return relativePath; } + + + /// + /// As but it also converts '\' to '/'. + /// + /// From path. + /// To path. + /// + /// Only works with file paths, which is ok, as it's used to create the {{Path}} macro. + public static string MakeRelativePathForUri(string fromPath, string toPath) + { + return Utils.MakeRelativePath(fromPath, toPath).Replace(@"\", @"/"); + } } }