Browse Source

Fixes #30

tags/0.13
Frans Bouma 10 years ago
parent
commit
a67bfae42f
2 changed files with 15 additions and 2 deletions
  1. +2
    -2
      src/DocNet/SimpleNavigationElement.cs
  2. +13
    -0
      src/DocNet/Utils.cs

+ 2
- 2
src/DocNet/SimpleNavigationElement.cs View File

@@ -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));


+ 13
- 0
src/DocNet/Utils.cs View File

@@ -184,5 +184,18 @@ namespace Docnet

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(@"\", @"/");
}
}
}

Loading…
Cancel
Save