Browse Source

Merge c660137dae into f18083fc6f

pull/61/merge
Geert van Horrik GitHub 8 years ago
parent
commit
943efade2b
1 changed files with 21 additions and 1 deletions
  1. +21
    -1
      src/DocNet/NavigationLevel.cs

+ 21
- 1
src/DocNet/NavigationLevel.cs View File

@@ -25,6 +25,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -299,11 +300,30 @@ namespace Docnet
{ {
path = Path.GetDirectoryName(this.ParentContainer.TargetURL); path = Path.GetDirectoryName(this.ParentContainer.TargetURL);
} }
var nameToUse = this.Name.Replace(".", "").Replace('/', '_').Replace("\\", "_").Replace(":", "").Replace(" ", "");

var nameToUse = this.Name;

var parent = this.ParentContainer;
while (parent != null)
{
nameToUse = $"{parent.Name}-{nameToUse}";

parent = parent.ParentContainer;
}

var regEx = new Regex("[^a-zA-Z0-9 -]");
nameToUse = regEx.Replace(nameToUse, "-").Replace(" ", "-");

while (nameToUse.Contains("--"))
{
nameToUse = nameToUse.Replace("--", "-");
}

if (string.IsNullOrWhiteSpace(nameToUse)) if (string.IsNullOrWhiteSpace(nameToUse))
{ {
return null; return null;
} }

toReturn = new SimpleNavigationElement() { ParentContainer = this, Value = string.Format("{0}{1}.md", path, nameToUse), Name = this.Name, IsIndexElement = true }; toReturn = new SimpleNavigationElement() { ParentContainer = this, Value = string.Format("{0}{1}.md", path, nameToUse), Name = this.Name, IsIndexElement = true };
this.Value.Add(toReturn); this.Value.Add(toReturn);
} }


Loading…
Cancel
Save