syntax-tree / mdast-util-to-markdown

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

roundtripping inline link with number in protocol and escapes causes link to disappear #23

Closed ChristianMurphy closed 3 years ago

ChristianMurphy commented 3 years ago

Subject of the issue

<www2:example\\>

is stringified as:

[www2:example\\\](www2:example\\\)

which changes the structure

Your environment

Steps to reproduce

parse

<www2:example\\>

which has the structure

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

and stringify it:

[www2:example\\\](www2:example\\\)

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 the sensitivity to a number in the protocol makes me think it may have a different root cause.

wooorm commented 3 years ago

The result from <www2:example\\> can now be roundtripped, so seems to be a duplicate. Not sure what you saw that lead to the conclusion that it was number related?