diff --git a/src/Markdig.Tests/MiscTests.cs b/src/Markdig.Tests/MiscTests.cs
index 7a2b2fc7..e9c5a70e 100644
--- a/src/Markdig.Tests/MiscTests.cs
+++ b/src/Markdig.Tests/MiscTests.cs
@@ -318,6 +318,26 @@ public void RootInlineInTableCellHasCorrectSourceSpan()
Assert.That(paragraph.Inline.Span.End == paragraph.Inline.LastChild.Span.End);
}
+ [Test]
+ public void TestGridTableShortLine()
+ {
+ var input = @"
++--+
+| |
++-";
+
+ var expected = @"
+";
+ 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 0dc268fa..6e6d562a 100644
--- a/src/Markdig/Extensions/Tables/GridTableParser.cs
+++ b/src/Markdig/Extensions/Tables/GridTableParser.cs
@@ -135,6 +135,7 @@ private BlockState HandleNewRow(BlockProcessor processor, GridTableState tableSt
private static void SetRowSpanState(List columns, StringSlice line, out bool isHeaderRow, out bool hasRowSpan)
{
var lineStart = line.Start;
+ var lineEnd = line.End;
isHeaderRow = line.PeekChar() == '=' || line.PeekChar(2) == '=';
hasRowSpan = false;
foreach (var columnSlice in columns)
@@ -142,7 +143,7 @@ private static void SetRowSpanState(List columns, St
if (columnSlice.CurrentCell != null)
{
line.Start = lineStart + columnSlice.Start + 1;
- line.End = lineStart + columnSlice.End - 1;
+ line.End = Math.Min(lineStart + columnSlice.End - 1, lineEnd);
line.Trim();
if (line.IsEmptyOrWhitespace() || !IsRowSeparator(line))
{