Skip to content

Commit 92033e5

Browse files
authored
fix: trim newline from blockquote token.text (#3037)
1 parent bbce7dd commit 92033e5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Tokenizer.ts

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

test/unit/Lexer-spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,27 @@ a | b
382382
});
383383
});
384384

385+
it('trim newline in text', () => {
386+
expectTokens({
387+
md: '> blockquote\n',
388+
tokens: [
389+
{
390+
type: 'blockquote',
391+
raw: '> blockquote\n',
392+
text: 'blockquote',
393+
tokens: [{
394+
type: 'paragraph',
395+
raw: 'blockquote',
396+
text: 'blockquote',
397+
tokens: [
398+
{ type: 'text', raw: 'blockquote', text: 'blockquote' }
399+
]
400+
}]
401+
}
402+
]
403+
});
404+
});
405+
385406
it('paragraph token in list', () => {
386407
expectTokens({
387408
md: '- > blockquote',

0 commit comments

Comments
 (0)