fix: trim newline from blockquote token.text (#3037)

This commit is contained in:
Tony Brix 2023-10-13 14:52:19 -05:00 committed by GitHub
parent bbce7dd0c2
commit 92033e57c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -156,7 +156,7 @@ export class _Tokenizer {
blockquote(src: string): Tokens.Blockquote | undefined { blockquote(src: string): Tokens.Blockquote | undefined {
const cap = this.rules.block.blockquote.exec(src); const cap = this.rules.block.blockquote.exec(src);
if (cap) { if (cap) {
const text = cap[0].replace(/^ *>[ \t]?/gm, ''); const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ''), '\n');
const top = this.lexer.state.top; const top = this.lexer.state.top;
this.lexer.state.top = true; this.lexer.state.top = true;
const tokens = this.lexer.blockTokens(text); const tokens = this.lexer.blockTokens(text);

View File

@ -382,6 +382,27 @@ a | b
}); });
}); });
it('trim newline in text', () => {
expectTokens({
md: '> blockquote\n',
tokens: [
{
type: 'blockquote',
raw: '> blockquote\n',
text: 'blockquote',
tokens: [{
type: 'paragraph',
raw: 'blockquote',
text: 'blockquote',
tokens: [
{ type: 'text', raw: 'blockquote', text: 'blockquote' }
]
}]
}
]
});
});
it('paragraph token in list', () => { it('paragraph token in list', () => {
expectTokens({ expectTokens({
md: '- > blockquote', md: '- > blockquote',