Skip to content

Commit a7e909c

Browse files
committed
fix: Add blank linkes before and after tables
1 parent 51d10e1 commit a7e909c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/MarkdownGenerator.Test/Internal/_DocumentSerializer/DocumentSerializerTest.cs

+32
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,38 @@ public void Tables_are_serialized_as_expected_02() =>
315315
new MdTableRow("Cell3", "Cell4")))
316316
);
317317

318+
[Fact]
319+
public void Tables_are_preceded_by_a_blank_line() =>
320+
AssertToStringEquals(
321+
"___\r\n" +
322+
"\r\n" +
323+
"| Column1 | Column2 |\r\n" +
324+
"| ------- | ------- |\r\n" +
325+
"| Cell1 | |\r\n" +
326+
"| Cell3 | Cell4 |\r\n",
327+
new MdDocument(
328+
new MdThematicBreak(),
329+
new MdTable(
330+
new MdTableRow("Column1", "Column2"),
331+
new MdTableRow("Cell1"),
332+
new MdTableRow("Cell3", "Cell4"))));
333+
334+
[Fact]
335+
public void Tables_are_followed_by_a_blank_line() =>
336+
AssertToStringEquals(
337+
"| Column1 | Column2 |\r\n" +
338+
"| ------- | ------- |\r\n" +
339+
"| Cell1 | |\r\n" +
340+
"| Cell3 | Cell4 |\r\n" +
341+
"\r\n" +
342+
"___\r\n",
343+
new MdDocument(
344+
new MdTable(
345+
new MdTableRow("Column1", "Column2"),
346+
new MdTableRow("Cell1"),
347+
new MdTableRow("Cell3", "Cell4")),
348+
new MdThematicBreak()));
349+
318350
[Fact]
319351
public void Serializer_respects_the_TableStyle_serialization_option()
320352
{

src/MarkdownGenerator/Internal/_DocumentSerializer/DocumentSerializer.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ void SaveRow(string[] row)
312312
m_Writer.WriteLine(lineBuilder.ToString());
313313
}
314314

315+
m_Writer.RequestBlankLine();
316+
315317
// save header row
316318
SaveRow(tableAsString[0]);
317319

@@ -331,7 +333,9 @@ void SaveRow(string[] row)
331333
foreach(var row in tableAsString.Skip(1))
332334
{
333335
SaveRow(row);
334-
}
336+
}
337+
338+
m_Writer.RequestBlankLine();
335339
}
336340

337341
public void SerializeHtmlTable(MdTable table)

0 commit comments

Comments
 (0)