Skip to content

Commit

Permalink
fix: trim newline from blockquote token.text (#3037)
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech authored Oct 13, 2023
1 parent bbce7dd commit 92033e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class _Tokenizer {
blockquote(src: string): Tokens.Blockquote | undefined {
const cap = this.rules.block.blockquote.exec(src);
if (cap) {
const text = cap[0].replace(/^ *>[ \t]?/gm, '');
const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ''), '\n');
const top = this.lexer.state.top;
this.lexer.state.top = true;
const tokens = this.lexer.blockTokens(text);
Expand Down
21 changes: 21 additions & 0 deletions test/unit/Lexer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
expectTokens({
md: '- > blockquote',
Expand Down

1 comment on commit 92033e5

@vercel
Copy link

@vercel vercel bot commented on 92033e5 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.