Skip to content

round tripping multiline header results in single line header #17

Closed
@ChristianMurphy

Description

@ChristianMurphy

Subject of the issue

text  
text-
-
text

is stringified as:

## text\
text-

text

which changes the structure

Your environment

  • OS: Ubuntu
  • Packages: mdast-util-to-markdown 0.6.4
  • Env: node v15.5.1, npm 7.3.0

Steps to reproduce

parse

text  
text-
-
text

which has the structure

{
    "type": "root",
    "children": [
        {
            "type": "heading",
            "depth": 2,
            "children": [
                {
                    "type": "text"
                },
                {
                    "type": "break"
                },
                {
                    "type": "text"
                }
            ]
        },
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text"
                }
            ]
        }
    ]
}

and stringify it:

## text\
text-

text

the resulting markdown has a different structure than the original

{
    "type": "root",
    "children": [
        {
            "type": "heading",
            "depth": 2,
            "children": [
                {
                    "type": "text"
                }
            ]
        },
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text"
                }
            ]
        },
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text"
                }
            ]
        }
    ]
}

📓 comparing how the two pieces of markdown text are being parsed with https://spec.commonmark.org/dingus it appears in both cases it is parsed as expected.

Expected behavior

structure is the same

Actual behavior

structure is different

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