Skip to content

Commit

Permalink
Merge pull request mixmark-io#143 from rspieker/master
Browse files Browse the repository at this point in the history
Don't remove empty table cells (fixes mixmark-io#137)
  • Loading branch information
domchristie committed Mar 15, 2016
2 parents 36e73cf + 1b7ceca commit 58d1568
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function process(node) {
var replacement, content = getContent(node);

// Remove blank nodes
if (!isVoid(node) && !/A/.test(node.nodeName) && /^\s*$/i.test(content)) {
if (!isVoid(node) && !/A|TH|TD/.test(node.nodeName) && /^\s*$/i.test(content)) {
node._replacement = '';
return;
}
Expand Down
55 changes: 54 additions & 1 deletion test/gfm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,60 @@ test('tables', function() {
'| Row 2, Column 1 | Row 2, Column 2 | Row 2, Column 3 | Row 2, Column 4 |'].join('\n'),

'Cell alignment'
]
],
[
['<table>',
' <thead>',
' <tr>',
' <th align="left">Column 1</th>',
' <th align="center">Column 2</th>',
' <th align="right">Column 3</th>',
' <th align="foo">Column 4</th>',
' </tr>',
' </thead>',
' <tbody>',
' <tr>',
' <td></td>',
' <td>Row 1, Column 2</td>',
' <td>Row 1, Column 3</td>',
' <td>Row 1, Column 4</td>',
' </tr>',
' <tr>',
' <td>Row 2, Column 1</td>',
' <td></td>',
' <td>Row 2, Column 3</td>',
' <td>Row 2, Column 4</td>',
' </tr>',
' <tr>',
' <td>Row 3, Column 1</td>',
' <td>Row 3, Column 2</td>',
' <td></td>',
' <td>Row 3, Column 4</td>',
' </tr>',
' <tr>',
' <td>Row 4, Column 1</td>',
' <td>Row 4, Column 2</td>',
' <td>Row 4, Column 3</td>',
' <td></td>',
' </tr>',
' <tr>',
' <td></td>',
' <td></td>',
' <td></td>',
' <td>Row 5, Column 4</td>',
' </tr>',
' </tbody',
'</table>'].join('\n'),
['| Column 1 | Column 2 | Column 3 | Column 4 |',
'| :-- | :-: | --: | --- |',
'| | Row 1, Column 2 | Row 1, Column 3 | Row 1, Column 4 |',
'| Row 2, Column 1 | | Row 2, Column 3 | Row 2, Column 4 |',
'| Row 3, Column 1 | Row 3, Column 2 | | Row 3, Column 4 |',
'| Row 4, Column 1 | Row 4, Column 2 | Row 4, Column 3 | |',
'| | | | Row 5, Column 4 |'
].join('\n'),
'Empty cells'
]
]);
});

Expand Down

0 comments on commit 58d1568

Please sign in to comment.