From f82ea2cf1be0a3ad3337bcafe1c4dd3182334bb9 Mon Sep 17 00:00:00 2001 From: Chell Date: Sun, 19 Dec 2021 08:21:22 +0800 Subject: [PATCH] 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 --- src/Tokenizer.js | 2 +- test/specs/new/tab_newline.html | 38 +++++++++++++++++++++++++++++++++ test/specs/new/tab_newline.md | 12 +++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/tab_newline.html create mode 100644 test/specs/new/tab_newline.md diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 61ed269a09..8ef871d606 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -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) { diff --git a/test/specs/new/tab_newline.html b/test/specs/new/tab_newline.html new file mode 100644 index 0000000000..77e5010172 --- /dev/null +++ b/test/specs/new/tab_newline.html @@ -0,0 +1,38 @@ + + + + + + + + + + + +
y
x
+ + + + + + + + + + + +
y
x
+ + + + + + + + + + + +
y
x
+
code
+
diff --git a/test/specs/new/tab_newline.md b/test/specs/new/tab_newline.md new file mode 100644 index 0000000000..5058d77d54 --- /dev/null +++ b/test/specs/new/tab_newline.md @@ -0,0 +1,12 @@ +| y | +| - | +| x | + +| y | +| - | +| x | + +| y | +| - | +| x | + code \ No newline at end of file