Skip to content

the result of lex a markdown text, which contains blockquote, contains a \n #3036

@tzq0301

Description

@tzq0301

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' }
]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions