Skip to content

Commit

Permalink
Correctly escape XML docs, closes #946
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoSuter committed Apr 11, 2019
1 parent 4643d38 commit 4aa91ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/NJsonSchema.CodeGeneration/DefaultTemplateFactory.cs
Expand Up @@ -177,7 +177,7 @@ internal static class LiquidFilters
{
public static string Csharpdocs(string input, int tabCount)
{
return ConversionUtilities.ConvertCSharpDocBreaks(input, tabCount);
return ConversionUtilities.ConvertCSharpDocs(input, tabCount);
}

public static string Tab(Context context, string input, int tabCount)
Expand Down
10 changes: 8 additions & 2 deletions src/NJsonSchema/ConversionUtilities.cs
Expand Up @@ -8,6 +8,7 @@

using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace NJsonSchema
{
Expand Down Expand Up @@ -151,9 +152,14 @@ public static string Tab(string input, int tabCount)
/// <param name="input">The input.</param>
/// <param name="tabCount">The tab count.</param>
/// <returns>The output.</returns>
public static string ConvertCSharpDocBreaks(string input, int tabCount)
public static string ConvertCSharpDocs(string input, int tabCount)
{
return input?.Replace("\r", string.Empty).Replace("\n", "\n" + string.Join("", Enumerable.Repeat(" ", tabCount)) + "/// ") ?? string.Empty;
input = input?
.Replace("\r", string.Empty)
.Replace("\n", "\n" + string.Join("", Enumerable.Repeat(" ", tabCount)) + "/// ")
?? string.Empty;

return new XText(input).ToString();
}

private static string ConvertDashesToCamelCase(string input)
Expand Down

0 comments on commit 4aa91ed

Please sign in to comment.