-
Notifications
You must be signed in to change notification settings - Fork 3.5k
the result of lex a markdown text, which contains blockquote, contains a \n #3036
Copy link
Copy link
Closed
Closed
Copy link
Labels
Description
Marked version: ^9.1.1
Describe the bug
the result of lex a markdown text, which contains blockquote, contains a \n
To Reproduce
import {marked} from "marked";
const lexer = new marked.Lexer();
const tokens = lexer.lex(`
# Hello World
> Preface
say sth.
## 1. One
1111
## 2. Two
2222
`)
.filter(token => token.type !== 'space')
.map(token => {
return {
type: token.type,
text: token.text,
};
});
console.log(tokens);the output is:
[
{ type: 'heading', text: 'Hello World' },
{ type: 'blockquote', text: 'Preface\n' },
{ type: 'paragraph', text: 'say sth.' },
{ type: 'heading', text: '1. One' },
{ type: 'paragraph', text: '1111' },
{ type: 'heading', text: '2. Two' },
{ type: 'paragraph', text: '2222' }
]
Expected behavior
my expected output is:
[
{ type: 'heading', text: 'Hello World' },
{ type: 'blockquote', text: 'Preface' }, // <- here, expect no '\n\
{ type: 'paragraph', text: 'say sth.' },
{ type: 'heading', text: '1. One' },
{ type: 'paragraph', text: '1111' },
{ type: 'heading', text: '2. Two' },
{ type: 'paragraph', text: '2222' }
]
Reactions are currently unavailable