Upstream xoofx/markdig state of the touched files before 0a17da190a
This commit is contained in:
1 parent
83afc8fa26
commit
b022656629
2 files changed
-91
No files matched your search
@@ -1,70 +0,0 @@
|
||||
// Copyright (c) Alexandre Mutel. All rights reserved.
|
||||
// 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.Roundtrip;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace Markdig.Tests;
|
||||
|
||||
[TestFixture]
|
||||
public class TestEmphasisRoundtrip
|
||||
{
|
||||
private static string RoundTrip(string markdown, MarkdownPipeline pipeline)
|
||||
{
|
||||
MarkdownDocument document = Markdown.Parse(markdown, pipeline);
|
||||
var writer = new StringWriter();
|
||||
var renderer = new RoundtripRenderer(writer);
|
||||
pipeline.Setup(renderer);
|
||||
renderer.Write(document);
|
||||
return writer.ToString();
|
||||
}
|
||||
|
||||
// A closer with leftover delimiter characters that dropped below the minimum count
|
||||
// used to stay nested inside the emphasis it closed, together with the content that
|
||||
// followed it. The round-tripped text then emitted the leftover run at the end of the
|
||||
// block. Reproduces https://github.com/xoofx/markdig/issues/743.
|
||||
[Test]
|
||||
public void GridTableSeparatorRoundtripsWithTrackTrivia()
|
||||
{
|
||||
string markdown =
|
||||
"+---------------+---------------+--------------------+\n" +
|
||||
"| Fruit | Price | Advantages |\n" +
|
||||
"+===============+===============+====================+\n" +
|
||||
"| Bananas | first line | first line |\n" +
|
||||
"| | next line | next line |\n" +
|
||||
"+---------------+---------------+--------------------+\n";
|
||||
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.UseAutoLinks()
|
||||
.UseEmphasisExtras()
|
||||
.UseListExtras()
|
||||
.EnableTrackTrivia()
|
||||
.Build();
|
||||
|
||||
Assert.That(RoundTrip(markdown, pipeline), Is.EqualTo(markdown));
|
||||
}
|
||||
|
||||
// Minimal reduction of the same defect: two '=' runs whose leftover characters
|
||||
// (15 = 7 * 2 + 1) fall below the "marked" (`==`) minimum count of 2.
|
||||
[Test]
|
||||
public void UnbalancedMarkedRunsRoundtrip()
|
||||
{
|
||||
string markdown = "+===============+===============+\n";
|
||||
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.UseEmphasisExtras()
|
||||
.EnableTrackTrivia()
|
||||
.Build();
|
||||
|
||||
Assert.That(RoundTrip(markdown, pipeline), Is.EqualTo(markdown));
|
||||
}
|
||||
|
||||
// The fix must not prevent balanced "marked" emphasis from being detected.
|
||||
[Test]
|
||||
public void BalancedMarkedEmphasisStillParses()
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder().UseEmphasisExtras().Build();
|
||||
Assert.That(Markdown.ToHtml("==bold==", pipeline).Trim(), Is.EqualTo("<p><mark>bold</mark></p>"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user