Skip to content

Commit 20209ee

Browse files
table: fix br inside table causing early return (#150)
1 parent 7fca0c1 commit 20209ee

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

‎plugin/table/2_collect.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func hasProblematicChildNode(node *html.Node) bool {
3232
// This will be caught with the newline check anyway.
3333
// But we can safe some effort by aborting early...
3434
return true
35-
case "br", "hr", "ul", "ol", "blockquote":
35+
case "hr", "ul", "ol", "blockquote":
3636
return true
3737
}
3838

@@ -104,6 +104,8 @@ func (p *tablePlugin) collectTableContent(ctx converter.Context, node *html.Node
104104
if containsNewline(cell) {
105105
// Having newlines inside the content would break the table.
106106
// So unfortunately we cannot convert the table.
107+
//
108+
// Note: We already trimmed the content earlier.
107109
return nil
108110
}
109111
}

‎plugin/table/testdata/GoldenFiles/contents.in.html‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@
1818
</tr>
1919
</table>
2020

21+
<hr />
22+
23+
<table>
24+
<tr>
25+
<td>
26+
with break after
27+
<br />
28+
</td>
29+
</tr>
30+
<tr>
31+
<td>
32+
<br />
33+
with break before
34+
</td>
35+
</tr>
36+
<tr>
37+
<td>
38+
<br /><br /><br />
39+
with break around
40+
<br /><br /><br />
41+
</td>
42+
</tr>
43+
</table>
44+
2145
<hr />
2246
<!-- yes: we can keep rendering a table (even though it contains a block node) -->
2347

‎plugin/table/testdata/GoldenFiles/contents.out.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
* * *
77

8+
| |
9+
|-------------------|
10+
| with break after |
11+
| with break before |
12+
| with break around |
13+
14+
* * *
15+
816
| |
917
|---------------------|
1018
| Some normal content |

0 commit comments

Comments
 (0)