From 191202999ec03948e3f22e9b324fb84aa71f25d3 Mon Sep 17 00:00:00 2001 From: Chell Date: Thu, 9 Dec 2021 19:49:13 +0800 Subject: [PATCH 1/8] fix: rename inconsistent function --- docs/USING_PRO.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/USING_PRO.md b/docs/USING_PRO.md index af4f1986c5..92c478094f 100644 --- a/docs/USING_PRO.md +++ b/docs/USING_PRO.md @@ -362,7 +362,7 @@ The renderer function has access to the parser in the `this` object, which can b **Example:** Add a custom syntax to generate `
` description lists. ``` js -const descriptionlist = { +const descriptionList = { name: 'descriptionList', level: 'block', // Is this a block-level or inline-level tokenizer? start(src) { return src.match(/:[^:\n]/)?.index; }, // Hint to Marked.js to stop and check for a match @@ -413,7 +413,7 @@ function walkTokens(token) { // Post-processing on the co token.tokens = this.Lexer.lexInline(token.text) } } -marked.use({ extensions: [descriptionlist, description], walkTokens }); +marked.use({ extensions: [descriptionList, description], walkTokens }); // EQUIVALENT TO: From 8cf79cda9d9623f08b4d338b6cc83caa44d6bdd4 Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 11 Dec 2021 19:21:20 +0800 Subject: [PATCH 2/8] fix: newline with 1~4 spaces below table --- src/Tokenizer.js | 4 ++++ test/specs/new/tab_newline.html | 12 ++++++++++++ test/specs/new/tab_newline.md | 4 ++++ 3 files changed, 20 insertions(+) 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 a957883f28..dde2bceaaf 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -374,6 +374,10 @@ export class Tokenizer { l = item.rows.length; for (i = 0; i < l; i++) { + if (/^\s{1,4}$/.test(item.rows[i])) { + item.rows.pop(); + continue; + } item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; }); } diff --git a/test/specs/new/tab_newline.html b/test/specs/new/tab_newline.html new file mode 100644 index 0000000000..c3c24491d3 --- /dev/null +++ b/test/specs/new/tab_newline.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
y
x
\ No newline at end of file diff --git a/test/specs/new/tab_newline.md b/test/specs/new/tab_newline.md new file mode 100644 index 0000000000..cec69eecce --- /dev/null +++ b/test/specs/new/tab_newline.md @@ -0,0 +1,4 @@ +| y | +| - | +| x | + \ No newline at end of file From a749222714fa8e416539cdf45df46b495951c45d Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 11 Dec 2021 21:33:49 +0800 Subject: [PATCH 3/8] fix: format html test --- test/specs/new/tab_newline.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/specs/new/tab_newline.html b/test/specs/new/tab_newline.html index c3c24491d3..075162190d 100644 --- a/test/specs/new/tab_newline.html +++ b/test/specs/new/tab_newline.html @@ -9,4 +9,4 @@ x - \ No newline at end of file + From edd5a9edb511f07d9625a5bf46afcb554c2c6991 Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 11 Dec 2021 21:51:23 +0800 Subject: [PATCH 4/8] fix: specify spaces only --- src/Tokenizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 22b37c9243..4a8b2c90d5 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -377,7 +377,7 @@ export class Tokenizer { l = item.rows.length; for (i = 0; i < l; i++) { - if (/^\s{1,4}$/.test(item.rows[i])) { + if (/^ {1,4}]$/.test(item.rows[i])) { item.rows.pop(); continue; } From fe1c2b010e146fb7a0240623332afe6287304ddd Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 11 Dec 2021 22:01:02 +0800 Subject: [PATCH 5/8] fix: specify spaces only --- src/Tokenizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 4a8b2c90d5..66709b832d 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -377,7 +377,7 @@ export class Tokenizer { l = item.rows.length; for (i = 0; i < l; i++) { - if (/^ {1,4}]$/.test(item.rows[i])) { + if (/^ {1,4}$/.test(item.rows[i])) { item.rows.pop(); continue; } From 245bb8f6c38621d01281efc925b4b5050a41ab3d Mon Sep 17 00:00:00 2001 From: Chell Date: Thu, 16 Dec 2021 18:13:44 +0800 Subject: [PATCH 6/8] fix: detect tab --- src/Tokenizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 66709b832d..0e657b58e6 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -377,7 +377,7 @@ export class Tokenizer { l = item.rows.length; for (i = 0; i < l; i++) { - if (/^ {1,4}$/.test(item.rows[i])) { + if (/(^ {1,4}$)|(^\t$)/.test(item.rows[i])) { item.rows.pop(); continue; } From e3a4559617bb52eef0b26581655b25756c98de62 Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 18 Dec 2021 12:52:29 +0800 Subject: [PATCH 7/8] fix: detect tab --- src/Tokenizer.js | 6 +----- test/specs/new/tab_newline.html | 26 ++++++++++++++++++++++++++ test/specs/new/tab_newline.md | 10 +++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 0e657b58e6..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) { @@ -377,10 +377,6 @@ export class Tokenizer { l = item.rows.length; for (i = 0; i < l; i++) { - if (/(^ {1,4}$)|(^\t$)/.test(item.rows[i])) { - item.rows.pop(); - continue; - } item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; }); } diff --git a/test/specs/new/tab_newline.html b/test/specs/new/tab_newline.html index 075162190d..9e1edbca6f 100644 --- a/test/specs/new/tab_newline.html +++ b/test/specs/new/tab_newline.html @@ -10,3 +10,29 @@ + + + + + + + + + + + +
y
x
+ + + + + + + + + + + +
y
x
+
code
+
\ No newline at end of file diff --git a/test/specs/new/tab_newline.md b/test/specs/new/tab_newline.md index cec69eecce..5058d77d54 100644 --- a/test/specs/new/tab_newline.md +++ b/test/specs/new/tab_newline.md @@ -1,4 +1,12 @@ | y | | - | | x | - \ No newline at end of file + +| y | +| - | +| x | + +| y | +| - | +| x | + code \ No newline at end of file From 8b05eab24e5d27a415a94dc5031b29caf197823b Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 18 Dec 2021 12:54:30 +0800 Subject: [PATCH 8/8] fix: newline at the end of html --- test/specs/new/tab_newline.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/specs/new/tab_newline.html b/test/specs/new/tab_newline.html index 9e1edbca6f..77e5010172 100644 --- a/test/specs/new/tab_newline.html +++ b/test/specs/new/tab_newline.html @@ -35,4 +35,4 @@
code
-
\ No newline at end of file +