mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-09 05:49:12 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0ee97a803 | ||
|
|
63ce549ea2 | ||
|
|
0faf0ef430 | ||
|
|
cdd4b40469 | ||
|
|
54d85ebac6 |
@@ -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))
|
||||
|
||||
@@ -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")]
|
||||
|
||||
17
src/Markdig.Tests/TestNewLine.cs
Normal file
17
src/Markdig.Tests/TestNewLine.cs
Normal 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")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 -->
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user