Skip to content

Commit

Permalink
adjust trim when generating table cells (#242)
Browse files Browse the repository at this point in the history
* fix first table's cell is ignored when empty

* add test #241
  • Loading branch information
simezi authored and quantizor committed Apr 18, 2019
1 parent b1f9b59 commit a5aa356
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
55 changes: 55 additions & 0 deletions index.compiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,61 @@ describe('GFM tables', () => {
</tbody>
</table>
`);
});

it('#241 should not ignore the first cell when its contents is empty', () => {
render(
compiler(
[
'| Foo | Bar | Baz |',
'| --- | --- | --- |',
'| | 2 | 3 |',
'| | 5 | 6 |',
].join('\n')
)
);

expect(root.innerHTML).toMatchInlineSnapshot(`
<table data-reactroot>
<thead>
<tr>
<th>
Foo
</th>
<th>
Bar
</th>
<th>
Baz
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
</td>
<td>
2
</td>
<td>
3
</td>
</tr>
<tr>
<td>
</td>
<td>
5
</td>
<td>
6
</td>
</tr>
</tbody>
</table>
`);
});

Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ function parseTableAlign(capture /*, parse, state*/) {

function parseTableCells(capture, parse, state) {
const rowsText = capture[3]
.replace(TABLE_TRIM_PIPES, '')
.trim()
.split('\n');

Expand Down

0 comments on commit a5aa356

Please sign in to comment.