Compare commits

..

5 Commits

Author SHA1 Message Date
Alexandre Mutel
c0ee97a803 Bump to 0.26.0 2021-08-27 20:34:30 +02:00
Alexandre Mutel
63ce549ea2 Merge pull request #570 from Sleepyowl/master
Fixes xoofx/markdig#567
2021-08-27 20:24:45 +02:00
Dmtry Soloviev
0faf0ef430 Make Mathematics extension respect EnableHtml* options 2021-08-24 23:03:02 +02:00
Alexandre Mutel
cdd4b40469 Merge pull request #560 from yufeih/yufeih/fix-crlf
Fix rendering diff between line endings
2021-07-06 18:36:32 +02:00
Yufei Huang
54d85ebac6 Fix rendering diff between line endings 2021-06-29 16:18:42 +08:00
9 changed files with 69 additions and 18 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## 0.26.0 (27 Aug 2021)
- Fix rendering diff between line endings ([PR #560](https://github.com/lunet-io/markdig/pull/560))
- Make Mathematics extension respect EnableHtml* options ([PR #570](https://github.com/lunet-io/markdig/pull/570))
## 0.25.0 (10 June 2021)
- Fix regression when parsing link reference definitions (#543)
- Make digits in JiraKey's posible ([PR #548](https://github.com/lunet-io/markdig/pull/548))

View File

@@ -115,9 +115,9 @@ namespace Markdig.Tests.RoundtripSpecs
}
//[TestCase("\n")]
//[TestCase("\r\n")]
//[TestCase("\r")]
[TestCase("\n")]
[TestCase("\r\n")]
[TestCase("\r")]
[TestCase("p\n")]
[TestCase("p\r")]

View File

@@ -0,0 +1,17 @@
using NUnit.Framework;
namespace Markdig.Tests
{
[TestFixture]
public class TestNewLine
{
[TestCase("a \nb", "<p>a<br />\nb</p>\n")]
[TestCase("a\\\nb", "<p>a<br />\nb</p>\n")]
[TestCase("a `b\nc`", "<p>a <code>b c</code></p>\n")]
public void Test(string value, string expectedHtml)
{
Assert.AreEqual(expectedHtml, Markdown.ToHtml(value));
Assert.AreEqual(expectedHtml, Markdown.ToHtml(value.Replace("\n", "\r\n")));
}
}
}

View File

@@ -1,5 +1,5 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
using Markdig.Renderers;
@@ -16,11 +16,19 @@ namespace Markdig.Extensions.Mathematics
protected override void Write(HtmlRenderer renderer, MathBlock obj)
{
renderer.EnsureLine();
renderer.Write("<div").WriteAttributes(obj).WriteLine(">");
renderer.WriteLine("\\[");
renderer.WriteLeafRawLines(obj, true, true);
renderer.Write("\\]");
renderer.WriteLine("</div>");
if (renderer.EnableHtmlForBlock)
{
renderer.Write("<div").WriteAttributes(obj).WriteLine(">");
renderer.WriteLine("\\[");
}
renderer.WriteLeafRawLines(obj, true, renderer.EnableHtmlEscape);
if (renderer.EnableHtmlForBlock)
{
renderer.Write("\\]");
renderer.WriteLine("</div>");
}
}
}
}

View File

@@ -1,5 +1,5 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
using Markdig.Renderers;
@@ -15,9 +15,24 @@ namespace Markdig.Extensions.Mathematics
{
protected override void Write(HtmlRenderer renderer, MathInline obj)
{
renderer.Write("<span").WriteAttributes(obj).Write(">\\(");
renderer.WriteEscape(ref obj.Content);
renderer.Write("\\)</span>");
if (renderer.EnableHtmlForInline)
{
renderer.Write("<span").WriteAttributes(obj).Write(">\\(");
}
if (renderer.EnableHtmlEscape)
{
renderer.WriteEscape(ref obj.Content);
}
else
{
renderer.Write(ref obj.Content);
}
if (renderer.EnableHtmlForInline)
{
renderer.Write("\\)</span>");
}
}
}
}

View File

@@ -4,7 +4,7 @@
<Description>A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET with 20+ builtin extensions (pipetables, footnotes, definition lists... etc.)</Description>
<Copyright>Alexandre Mutel</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>0.25.0</VersionPrefix>
<VersionPrefix>0.26.0</VersionPrefix>
<Authors>Alexandre Mutel</Authors>
<!-- Markdig.Wpf still supports net452, a target still supported by by Microsoft until January 10, 2023 -->
<!-- see: https://github.com/xoofx/markdig/pull/466 -->

View File

@@ -1,5 +1,5 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
using Markdig.Helpers;
@@ -63,6 +63,12 @@ namespace Markdig.Parsers.Inlines
{
c = ' ';
}
else if (c == '\r')
{
slice.SkipChar();
c = slice.CurrentChar;
continue;
}
if (c == match)
{

View File

@@ -1,5 +1,5 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
using Markdig.Helpers;
@@ -66,7 +66,7 @@ namespace Markdig.Parsers.Inlines
}
else
{
if (c == '\n')
if (c == '\n' || c == '\r')
{
processor.Inline = new LineBreakInline()
{

View File

@@ -52,7 +52,8 @@ namespace Markdig.Parsers.Inlines
length = nextStart - slice.Start;
if (!processor.TrackTrivia)
{
if (text[nextStart] == '\n')
var nextText = text[nextStart];
if (nextText == '\n' || nextText == '\r')
{
int end = nextStart - 1;
while (length > 0 && text[end].IsSpace())