Skip to content

Commit f82ea2c

Browse files
authored
fix: spaces on a newline after a table (#2319)
* 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
1 parent fbc08fb commit f82ea2c

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/Tokenizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export class Tokenizer {
355355
type: 'table',
356356
header: splitCells(cap[1]).map(c => { return { text: c }; }),
357357
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
358-
rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
358+
rows: cap[3] ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
359359
};
360360

361361
if (item.header.length === item.align.length) {

test/specs/new/tab_newline.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<table>
2+
<thead>
3+
<tr>
4+
<th>y</th>
5+
</tr>
6+
</thead>
7+
<tbody>
8+
<tr>
9+
<td>x</td>
10+
</tr>
11+
</tbody>
12+
</table>
13+
<table>
14+
<thead>
15+
<tr>
16+
<th>y</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td>x</td>
22+
</tr>
23+
</tbody>
24+
</table>
25+
<table>
26+
<thead>
27+
<tr>
28+
<th>y</th>
29+
</tr>
30+
</thead>
31+
<tbody>
32+
<tr>
33+
<td>x</td>
34+
</tr>
35+
</tbody>
36+
</table>
37+
<pre><code>code
38+
</code></pre>

test/specs/new/tab_newline.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
| y |
2+
| - |
3+
| x |
4+
5+
| y |
6+
| - |
7+
| x |
8+
9+
| y |
10+
| - |
11+
| x |
12+
code

0 commit comments

Comments
 (0)