From 13ab6f0f15bc1258d97fee655da5b0f143289a50 Mon Sep 17 00:00:00 2001 From: Frans Bouma Date: Wed, 9 Mar 2016 13:28:47 +0100 Subject: [PATCH] Bugfix for include filenames containing quotes. Changes for #32. --- src/DocNet/Config.cs | 9 +++++++++ src/DocNet/Properties/AssemblyInfo.cs | 4 ++-- src/DocNet/SimpleNavigationElement.cs | 2 +- src/DocNet/Utils.cs | 7 ++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/DocNet/Config.cs b/src/DocNet/Config.cs index 5d2dc5a..4013e05 100644 --- a/src/DocNet/Config.cs +++ b/src/DocNet/Config.cs @@ -198,6 +198,15 @@ namespace Docnet return _destinationPath; } } + + public string IncludeFolder + { + get + { + string rawIncludeFolder = _configData.IncludeSource; + return string.IsNullOrWhiteSpace(rawIncludeFolder) ? "Includes" : rawIncludeFolder; + } + } public string ThemeName { diff --git a/src/DocNet/Properties/AssemblyInfo.cs b/src/DocNet/Properties/AssemblyInfo.cs index 410bf33..0a1bb1e 100644 --- a/src/DocNet/Properties/AssemblyInfo.cs +++ b/src/DocNet/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.10.1.0")] -[assembly: AssemblyFileVersion("0.10.1")] +[assembly: AssemblyVersion("0.11.0.0")] +[assembly: AssemblyFileVersion("0.11.0")] diff --git a/src/DocNet/SimpleNavigationElement.cs b/src/DocNet/SimpleNavigationElement.cs index eb59dc2..53ba3fa 100644 --- a/src/DocNet/SimpleNavigationElement.cs +++ b/src/DocNet/SimpleNavigationElement.cs @@ -67,7 +67,7 @@ namespace Docnet { this.MarkdownFromFile = File.ReadAllText(sourceFile); // Check if the content contains @@include tag - content = Utils.IncludeProcessor(this.MarkdownFromFile, Path.Combine(activeConfig.Source, "Includes")); + content = Utils.IncludeProcessor(this.MarkdownFromFile, Utils.MakeAbsolutePath(activeConfig.Source, activeConfig.IncludeFolder)); content = Utils.ConvertMarkdownToHtml(content, Path.GetDirectoryName(destinationFile), activeConfig.Destination, _relativeH2LinksOnPage); } else diff --git a/src/DocNet/Utils.cs b/src/DocNet/Utils.cs index 738cb1b..23f9a94 100644 --- a/src/DocNet/Utils.cs +++ b/src/DocNet/Utils.cs @@ -212,9 +212,9 @@ namespace Docnet /// into the output. /// /// content to be scanned for include tags - /// Directory containing the include files + /// Directory containing the include files (absolute folder) /// String with @@include replaced with the actual content from the partial. - public static string IncludeProcessor(String content, string includePath) + public static string IncludeProcessor(String content, string includeFolder) { Match m = includeRegex.Match(content); while (m.Success) @@ -223,7 +223,8 @@ namespace Docnet { string tagToReplace = m.Groups[0].Value; string fileName = m.Groups[1].Value; - string filePath = Path.Combine(includePath, fileName); + fileName = fileName.Replace("\"", ""); + string filePath = Path.Combine(includeFolder, fileName); if (File.Exists(filePath)) { content = content.Replace(tagToReplace, File.ReadAllText(filePath));