Fix issue when the last character of a table is not a newline and there are spaces in-between (issue #73)

This commit is contained in:
Alexandre Mutel
2016-11-29 17:43:28 +01:00
parent f668b3fe38
commit f11d8037ac
2 changed files with 35 additions and 2 deletions

View File

@@ -118,7 +118,7 @@ blabla
[Test]
public void TestBugAdvancaed()
public void TestBugAdvanced()
{
TestParser.TestSpec(@"`https://{domain}/callbacks`
#### HEADING
@@ -126,6 +126,30 @@ Paragraph
", "<p><code>https://{domain}/callbacks</code></p>\n<h4 id=\"heading\">HEADING</h4>\n<p>Paragraph</p>", "advanced");
}
[Test]
public void TestBugPipeTables()
{
// https://github.com/lunet-io/markdig/issues/73
TestParser.TestSpec(@"| abc | def |
| --- | --- |
| 1 | ~3 |
", @"<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>~3</td>
</tr>
</tbody>
</table>", "advanced");
}
[Test]
public void TestSamePipelineAllExtensions()
{

View File

@@ -274,7 +274,16 @@ namespace Markdig.Extensions.Tables
}
var endOfTable = new LineBreakInline();
lastElement.InsertAfter(endOfTable);
// If the last element is a container, we have to add the EOL to its child
// otherwise only next sibling
if (lastElement is ContainerInline)
{
((ContainerInline)lastElement).AppendChild(endOfTable);
}
else
{
lastElement.InsertAfter(endOfTable);
}
delimiters.Add(endOfTable);
tableState.EndOfLines.Add(endOfTable);
}