Skip to content

Commit

Permalink
fix: spaces on a newline after a table (#2319)
Browse files Browse the repository at this point in the history
* fix: rename inconsistent function

* fix: newline with 1~4 spaces below table

* fix: format html test

* fix: specify spaces only

* fix: specify spaces only

* fix: detect tab

* fix: detect tab

* fix: newline at the end of html
  • Loading branch information
cyanxiao authored Dec 19, 2021
1 parent fbc08fb commit f82ea2c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class Tokenizer {
type: 'table',
header: splitCells(cap[1]).map(c => { return { text: c }; }),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
rows: cap[3] ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
};

if (item.header.length === item.align.length) {
Expand Down
38 changes: 38 additions & 0 deletions test/specs/new/tab_newline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<table>
<thead>
<tr>
<th>y</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>y</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>y</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
</tr>
</tbody>
</table>
<pre><code>code
</code></pre>
12 changes: 12 additions & 0 deletions test/specs/new/tab_newline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
| y |
| - |
| x |

| y |
| - |
| x |

| y |
| - |
| x |
code

1 comment on commit f82ea2c

@vercel
Copy link

@vercel vercel bot commented on f82ea2c Dec 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.