Skip to content

Commit

Permalink
Merge pull request #340 from MihaZupan/master
Browse files Browse the repository at this point in the history
Fix regression from #315
  • Loading branch information
xoofx committed May 13, 2019
2 parents ea13b33 + 6d3a358 commit f879d55
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@
*.userosscache
*.sln.docstates
*.nuget.props
*.nuget.targets

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
@@ -1,5 +1,8 @@
# Changelog

## WIP
- Fix regression when escaping HTML characters ([(PR #340)](https://github.com/lunet-io/markdig/pull/340))

## 0.17.0 (10 May 2019)
- Update to latest CommonMark specs 0.29 ([(PR #327)](https://github.com/lunet-io/markdig/pull/327))
- Add `AutoLinkOptions` with `OpenInNewWindow`, `UseHttpsForWWWLinks` ([(PR #327)](https://github.com/lunet-io/markdig/pull/327))
Expand Down
8 changes: 8 additions & 0 deletions src/Markdig.Tests/MiscTests.cs
Expand Up @@ -8,6 +8,14 @@ namespace Markdig.Tests
{
public class MiscTests
{
[Test]
public void TestAltTextIsCorrectlyEscaped()
{
TestParser.TestSpec(
@"![This is image alt text with quotation ' and double quotation ""hello"" world](girl.png)",
@"<p><img src=""girl.png"" alt=""This is image alt text with quotation ' and double quotation &quot;hello&quot; world"" /></p>");
}

[Test]
public void TestChangelogPRLinksMatchDescription()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Markdig/Markdown.cs
Expand Up @@ -184,7 +184,8 @@ public static MarkdownDocument ToPlainText(string markdown, TextWriter writer, M
var renderer = new HtmlRenderer(writer)
{
EnableHtmlForBlock = false,
EnableHtmlForInline = false
EnableHtmlForInline = false,
EnableHtmlEscape = false,
};
pipeline.Setup(renderer);

Expand Down
Expand Up @@ -13,7 +13,7 @@ public class HtmlEntityInlineRenderer : HtmlObjectRenderer<HtmlEntityInline>
{
protected override void Write(HtmlRenderer renderer, HtmlEntityInline obj)
{
if (renderer.EnableHtmlForInline)
if (renderer.EnableHtmlEscape)
{
renderer.WriteEscape(obj.Transcoded);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Markdig/Renderers/Html/Inlines/LiteralInlineRenderer.cs
Expand Up @@ -13,13 +13,13 @@ public class LiteralInlineRenderer : HtmlObjectRenderer<LiteralInline>
{
protected override void Write(HtmlRenderer renderer, LiteralInline obj)
{
if (renderer.EnableHtmlForInline)
if (renderer.EnableHtmlEscape)
{
renderer.WriteEscape(obj.Content);
renderer.WriteEscape(ref obj.Content);
}
else
{
renderer.Write(obj.Content);
renderer.Write(ref obj.Content);
}
}
}
Expand Down

0 comments on commit f879d55

Please sign in to comment.