diff --git a/src/Markdig.Tests/RoundtripSpecs/TestParagraph.cs b/src/Markdig.Tests/RoundtripSpecs/TestParagraph.cs
index 27603da98..3da89f1ca 100644
--- a/src/Markdig.Tests/RoundtripSpecs/TestParagraph.cs
+++ b/src/Markdig.Tests/RoundtripSpecs/TestParagraph.cs
@@ -115,9 +115,9 @@ public void Test(string value)
}
- //[TestCase("\n")]
- //[TestCase("\r\n")]
- //[TestCase("\r")]
+ [TestCase("\n")]
+ [TestCase("\r\n")]
+ [TestCase("\r")]
[TestCase("p\n")]
[TestCase("p\r")]
diff --git a/src/Markdig.Tests/TestNewLine.cs b/src/Markdig.Tests/TestNewLine.cs
new file mode 100644
index 000000000..cf54563bd
--- /dev/null
+++ b/src/Markdig.Tests/TestNewLine.cs
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace Markdig.Tests
+{
+ [TestFixture]
+ public class TestNewLine
+ {
+ [TestCase("a \nb", "
a
\nb
\n")]
+ [TestCase("a\\\nb", "a
\nb
\n")]
+ [TestCase("a `b\nc`", "a b c
\n")]
+ public void Test(string value, string expectedHtml)
+ {
+ Assert.AreEqual(expectedHtml, Markdown.ToHtml(value));
+ Assert.AreEqual(expectedHtml, Markdown.ToHtml(value.Replace("\n", "\r\n")));
+ }
+ }
+}
diff --git a/src/Markdig/Parsers/Inlines/CodeInlineParser.cs b/src/Markdig/Parsers/Inlines/CodeInlineParser.cs
index 1636ada0e..cd243ec6a 100644
--- a/src/Markdig/Parsers/Inlines/CodeInlineParser.cs
+++ b/src/Markdig/Parsers/Inlines/CodeInlineParser.cs
@@ -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 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
{
c = ' ';
}
+ else if (c == '\r')
+ {
+ slice.SkipChar();
+ c = slice.CurrentChar;
+ continue;
+ }
if (c == match)
{
diff --git a/src/Markdig/Parsers/Inlines/EscapeInlineParser.cs b/src/Markdig/Parsers/Inlines/EscapeInlineParser.cs
index a85c6d82e..5a66a5dcc 100644
--- a/src/Markdig/Parsers/Inlines/EscapeInlineParser.cs
+++ b/src/Markdig/Parsers/Inlines/EscapeInlineParser.cs
@@ -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 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
}
else
{
- if (c == '\n')
+ if (c == '\n' || c == '\r')
{
processor.Inline = new LineBreakInline()
{
diff --git a/src/Markdig/Parsers/Inlines/LiteralInlineParser.cs b/src/Markdig/Parsers/Inlines/LiteralInlineParser.cs
index 636c3f72b..38a414b2a 100644
--- a/src/Markdig/Parsers/Inlines/LiteralInlineParser.cs
+++ b/src/Markdig/Parsers/Inlines/LiteralInlineParser.cs
@@ -52,7 +52,8 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
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())