Skip to content

Commit

Permalink
Merge pull request #406 from FranklinWhale/patch-1
Browse files Browse the repository at this point in the history
Make output of HtmlTableRenderer XML wellformed
  • Loading branch information
xoofx authored Mar 8, 2020
2 parents 70ee97d + 5548246 commit e1ba52d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
42 changes: 21 additions & 21 deletions src/Markdig.Tests/Specs/GridTableSpecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ The following is a valid row separator
| This is | a table |
.
<table>
<col style="width:50%">
<col style="width:50%">
<col style="width:50%" />
<col style="width:50%" />
<tbody>
<tr>
<td>This is</td>
Expand Down Expand Up @@ -74,9 +74,9 @@ A regular row can continue a previous regular row when column separator `|` are
| Col1c |
.
<table>
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%" />
<col style="width:33.33%" />
<col style="width:33.33%" />
<tbody>
<tr>
<td>Col1
Expand Down Expand Up @@ -105,8 +105,8 @@ A row header is separated using `+========+` instead of `+---------+`:
+=========+=========+
.
<table>
<col style="width:50%">
<col style="width:50%">
<col style="width:50%" />
<col style="width:50%" />
<thead>
<tr>
<th>This is</th>
Expand All @@ -123,8 +123,8 @@ The last column separator `|` may be omitted:
| This is | a table with a longer text in the second column
.
<table>
<col style="width:50%">
<col style="width:50%">
<col style="width:50%" />
<col style="width:50%" />
<tbody>
<tr>
<td>This is</td>
Expand All @@ -150,9 +150,9 @@ So the width would be 4/16 = 25%, 8/16 = 50%, 4/16 = 25%
+----+--------+----+
.
<table>
<col style="width:25%">
<col style="width:50%">
<col style="width:25%">
<col style="width:25%" />
<col style="width:50%" />
<col style="width:25%" />
<tbody>
<tr>
<td>A</td>
Expand All @@ -172,9 +172,9 @@ Alignment might be specified on the first row using the character `:`:
+-----+-----+-----+
.
<table>
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%" />
<col style="width:33.33%" />
<col style="width:33.33%" />
<tbody>
<tr>
<td>A</td>
Expand All @@ -197,9 +197,9 @@ Alignment might be specified on the first row using the character `:`:
+---+---+---+
.
<table>
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%" />
<col style="width:33.33%" />
<col style="width:33.33%" />
<tbody>
<tr>
<td colspan="2">AAAAA</td>
Expand Down Expand Up @@ -232,9 +232,9 @@ A grid table may have cells with both colspan and rowspan:
+---+---+---+
.
<table>
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%">
<col style="width:33.33%" />
<col style="width:33.33%" />
<col style="width:33.33%" />
<tbody>
<tr>
<td colspan="2" rowspan="2">AAAAA
Expand Down
14 changes: 7 additions & 7 deletions src/Markdig.Tests/TestPlayParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
using System;
using System.Linq;
Expand All @@ -19,7 +19,7 @@ public void TestLink()
var link = doc.Descendants<ParagraphBlock>().SelectMany(x => x.Inline.Descendants<LinkInline>()).FirstOrDefault(l => l.IsImage);
Assert.AreEqual("/yoyo", link?.Url);
}

[Test]
public void TestListBug2()
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public void TestSimple()
[Test]
public void TestEmptyLiteral()
{
var text = @"> *some text*
var text = @"> *some text*
> some other text";
var doc = Markdown.Parse(text);

Expand Down Expand Up @@ -195,8 +195,8 @@ public void TestGridTableWithCustomAttributes() {
";

var expected = @"<table class=""table"">
<col style=""width:50%"">
<col style=""width:50%"">
<col style=""width:50%"" />
<col style=""width:50%"" />
<thead>
<tr>
<th>a</th>
Expand All @@ -219,7 +219,7 @@ public void TestSamePipelineAllExtensions()
{
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();

// Reuse the same pipeline
// Reuse the same pipeline
var result1 = Markdown.ToHtml("This is a \"\"citation\"\"", pipeline);
var result2 = Markdown.ToHtml("This is a \"\"citation\"\"", pipeline);

Expand Down Expand Up @@ -269,7 +269,7 @@ public void TestSamePipelineAllExtensions()
//| Yes |
//| ``` |
//+===================================+======================================+
//| This is a second line |
//| This is a second line |
//+-----------------------------------+--------------------------------------+

//:::spoiler {#yessss}
Expand Down
4 changes: 2 additions & 2 deletions src/Markdig/Extensions/Tables/HtmlTableRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override void Write(HtmlRenderer renderer, Table table)
{
var width = Math.Round(tableColumnDefinition.Width*100)/100;
var widthValue = string.Format(CultureInfo.InvariantCulture, "{0:0.##}", width);
renderer.WriteLine($"<col style=\"width:{widthValue}%\">");
renderer.WriteLine($"<col style=\"width:{widthValue}%\" />");
}
}

Expand Down Expand Up @@ -135,4 +135,4 @@ protected override void Write(HtmlRenderer renderer, Table table)
renderer.WriteLine("</table>");
}
}
}
}

0 comments on commit e1ba52d

Please sign in to comment.