Merge pull request #340 from MihaZupan/master

Fix regression from #315
This commit is contained in:
Alexandre Mutel
2019-05-13 10:46:59 +02:00
committed by GitHub
6 changed files with 18 additions and 5 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@
*.userosscache
*.sln.docstates
*.nuget.props
*.nuget.targets
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

View File

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

View File

@@ -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()
{

View File

@@ -184,7 +184,8 @@ namespace Markdig
var renderer = new HtmlRenderer(writer)
{
EnableHtmlForBlock = false,
EnableHtmlForInline = false
EnableHtmlForInline = false,
EnableHtmlEscape = false,
};
pipeline.Setup(renderer);

View File

@@ -13,7 +13,7 @@ namespace Markdig.Renderers.Html.Inlines
{
protected override void Write(HtmlRenderer renderer, HtmlEntityInline obj)
{
if (renderer.EnableHtmlForInline)
if (renderer.EnableHtmlEscape)
{
renderer.WriteEscape(obj.Transcoded);
}

View File

@@ -13,13 +13,13 @@ namespace Markdig.Renderers.Html.Inlines
{
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);
}
}
}