Skip to content

Commit

Permalink
Fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
FransBouma committed Mar 7, 2016
1 parent dd2e6db commit a67bfae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DocNet/SimpleNavigationElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public override void GenerateOutput(Config activeConfig, NavigatedPath activePat
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);
Expand All @@ -84,7 +85,7 @@ public override void GenerateOutput(Config activeConfig, NavigatedPath activePat
{
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);
Expand All @@ -103,7 +104,6 @@ public override void GenerateOutput(Config activeConfig, NavigatedPath activePat
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));
Expand Down
13 changes: 13 additions & 0 deletions src/DocNet/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,18 @@ public static string MakeRelativePath(string fromPath, string toPath)

return relativePath;
}


/// <summary>
/// As <see cref="MakeRelativePath"/> but it also converts '\' to '/'.
/// </summary>
/// <param name="fromPath">From path.</param>
/// <param name="toPath">To path.</param>
/// <returns></returns>
/// <remarks>Only works with file paths, which is ok, as it's used to create the {{Path}} macro.</remarks>
public static string MakeRelativePathForUri(string fromPath, string toPath)
{
return Utils.MakeRelativePath(fromPath, toPath).Replace(@"\", @"/");
}
}
}

0 comments on commit a67bfae

Please sign in to comment.