mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-04 05:44:50 +00:00
fix SetextHeading tests
This commit is contained in:
@@ -41,6 +41,10 @@ namespace Markdig.Tests.RoundtripSpecs
|
||||
[TestCase("h1\r===\r\n")]
|
||||
[TestCase("h1\n===\r\n")]
|
||||
[TestCase("h1\r\n===\r\n")]
|
||||
|
||||
[TestCase("h1\n===\n\n\nh2---\n\n")]
|
||||
[TestCase("h1\r===\r\r\rh2---\r\r")]
|
||||
[TestCase("h1\r\n===\r\n\r\n\r\nh2---\r\n\r\n")]
|
||||
public void TestNewline(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
|
||||
@@ -180,21 +180,14 @@ namespace Markdig.Parsers
|
||||
|
||||
public int WhitespaceStart { get; set; }
|
||||
|
||||
// NOTE: Line.Text is full source, not the line (!)
|
||||
public StringSlice PopBeforeWhitespace(int end)
|
||||
{
|
||||
// NOTE: Line.Text is full source, not the line (!)
|
||||
var stringSlice = new StringSlice(Line.Text, WhitespaceStart, end);
|
||||
WhitespaceStart = end + 1;
|
||||
return stringSlice;
|
||||
}
|
||||
|
||||
public StringSlice PopBeforeWhitespace(int start, int end)
|
||||
{
|
||||
var stringSlice = new StringSlice(Line.Text, start, end);
|
||||
WhitespaceStart = end + 1;
|
||||
return stringSlice;
|
||||
}
|
||||
|
||||
public List<StringSlice> BeforeLines { get; set; }
|
||||
public bool TrackTrivia { get => trackTrivia; set => trackTrivia = value; }
|
||||
|
||||
|
||||
@@ -209,6 +209,7 @@ namespace Markdig.Parsers
|
||||
return BlockState.None;
|
||||
}
|
||||
var bulletLength = 1; // TODO: RTP: fix for ordered
|
||||
var savedWhitespaceStart = state.WhitespaceStart;
|
||||
var whitespaceBefore = state.PopBeforeWhitespace(state.Start - bulletLength - 1);
|
||||
state.WhitespaceStart = state.Start;
|
||||
|
||||
@@ -231,6 +232,7 @@ namespace Markdig.Parsers
|
||||
if (!c.IsSpaceOrTab())
|
||||
{
|
||||
state.GoToColumn(initColumn);
|
||||
state.WhitespaceStart = savedWhitespaceStart; // restore changed WhitespaceStart state
|
||||
return BlockState.None;
|
||||
}
|
||||
|
||||
@@ -261,6 +263,7 @@ namespace Markdig.Parsers
|
||||
state.IsOpen(previousParagraph) && listInfo.BulletType == '1' && listInfo.OrderedStart != "1")
|
||||
{
|
||||
state.GoToColumn(initColumn);
|
||||
state.WhitespaceStart = savedWhitespaceStart; // restore changed WhitespaceStart state
|
||||
return BlockState.None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,15 +115,15 @@ namespace Markdig.Parsers
|
||||
Span = new SourceSpan(paragraph.Span.Start, line.Start),
|
||||
Level = level,
|
||||
Lines = paragraph.Lines,
|
||||
BeforeWhitespace = state.PopBeforeWhitespace(sourcePosition - 1),
|
||||
BeforeWhitespace = state.PopBeforeWhitespace(sourcePosition - 1), // remove dashes
|
||||
AfterWhitespace = new StringSlice(state.Line.Text, state.Start, line.End),
|
||||
LinesBefore = state.UseLinesBefore(),
|
||||
LinesBefore = paragraph.LinesBefore,
|
||||
Newline = state.Line.Newline,
|
||||
IsSetext = true,
|
||||
HeaderCharCount = count,
|
||||
SetextNewline = paragraph.Newline,
|
||||
};
|
||||
//heading.Lines.Trim();
|
||||
//heading.Lines.Trim(); // TODO: RTP: fix
|
||||
|
||||
// Remove the paragraph as a pending block
|
||||
state.NewBlocks.Push(heading);
|
||||
|
||||
Reference in New Issue
Block a user