syntax-tree / mdast-util-to-markdown

mdast utility to serialize markdown
http://unifiedjs.com
MIT License
100 stars 20 forks source link

roundtripping escape before break causes break to disappear #22

Closed ChristianMurphy closed 3 years ago

ChristianMurphy commented 3 years ago

Subject of the issue

text\\\\\
text

is stringified as:

text\\\\
text

which changes the structure

Your environment

Steps to reproduce

parse

text\\\\\
text

which has the structure

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

and stringify it:

text\\\\
text

the resulting markdown has a different structure than the original

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

:notebook: 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

ChristianMurphy commented 3 years ago

related to #19 but being space related rather than inline block related may mean it has a different cause.

wooorm commented 3 years ago

Yup, was GH-19.