diff --git a/src/Markdig.Tests/MiscTests.cs b/src/Markdig.Tests/MiscTests.cs index ca5ad4c..1dcc9f0 100644 --- a/src/Markdig.Tests/MiscTests.cs +++ b/src/Markdig.Tests/MiscTests.cs @@ -346,6 +346,31 @@ $$ TestParser.TestSpec(input, expected, new MarkdownPipelineBuilder().UseGridTables().Build()); } + [Test] + public void TestGridTableLastCellWithoutClosingPipe() + { + // The last cell is open and shorter than the column, and the next line has + // a `|` where this one would end: https://github.com/xoofx/markdig/issues/494 + var input = @" ++-----+----------+ +| 6 | 1 +| | ++-----+----------+"; + + var expected = @" +++ + + + + + +
61
+"; + TestParser.TestSpec(input, expected, new MarkdownPipelineBuilder().UseGridTables().Build()); + } + [Test] public void TestDefinitionListInListItemWithBlankLine() { diff --git a/src/Markdig/Extensions/Tables/GridTableParser.cs b/src/Markdig/Extensions/Tables/GridTableParser.cs index 35de6f1..20aec86 100644 --- a/src/Markdig/Extensions/Tables/GridTableParser.cs +++ b/src/Markdig/Extensions/Tables/GridTableParser.cs @@ -279,7 +279,7 @@ public class GridTableParser : BlockParser else { var columnEnd = columns[columns.Count - 1].End; - var columnEndChar = line.PeekCharExtra(columnEnd); + var columnEndChar = line.PeekChar(columnEnd); // If there is a `|` (or a `+` in the case that we are dealing with a row line // with spanned contents) exactly at the expected end of the table row, we cut the line // otherwise we allow to have the last cell of a row to be open for longer cell content