From dace1109a8ffa4ed96d48a8110d75ebda3a45156 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 30 Nov 2022 01:07:29 -0600 Subject: [PATCH] fix: use paragraph token in blockquote in list --- src/Tokenizer.js | 7 +++++-- test/unit/Lexer-spec.js | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 42064621b4..d83409e70b 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -149,11 +149,14 @@ export class Tokenizer { const cap = this.rules.block.blockquote.exec(src); if (cap) { const text = cap[0].replace(/^ *>[ \t]?/gm, ''); - + const top = this.lexer.state.top; + this.lexer.state.top = true; + const tokens = this.lexer.blockTokens(text); + this.lexer.state.top = top; return { type: 'blockquote', raw: cap[0], - tokens: this.lexer.blockTokens(text, []), + tokens, text }; } diff --git a/test/unit/Lexer-spec.js b/test/unit/Lexer-spec.js index 7a1e826fd8..256de20d1c 100644 --- a/test/unit/Lexer-spec.js +++ b/test/unit/Lexer-spec.js @@ -381,6 +381,48 @@ a | b ] }); }); + + it('paragraph token in list', () => { + expectTokens({ + md: '- > blockquote', + tokens: [ + { + type: 'list', + raw: '- > blockquote', + ordered: false, + start: '', + loose: false, + items: [ + { + type: 'list_item', + raw: '- > blockquote', + task: false, + checked: undefined, + loose: false, + text: '> blockquote', + tokens: [ + { + type: 'blockquote', + raw: '> blockquote', + tokens: [ + { + type: 'paragraph', + raw: 'blockquote', + text: 'blockquote', + tokens: [ + { type: 'text', raw: 'blockquote', text: 'blockquote' } + ] + } + ], + text: 'blockquote' + } + ] + } + ] + } + ] + }); + }); }); describe('list', () => {