Skip to content

roundtripping emphasis in emphasis edge case changes document structure #12

Open
@ChristianMurphy

Description

@ChristianMurphy

Subject of the issue

***emphasis*in emphasis*

is stringified as:

\***emphasis*in emphasis*

which changes the structure

Your environment

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

Steps to reproduce

parse

***emphasis*in emphasis*

which has the structure

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

and stringify it:

\***emphasis*in emphasis*

the resulting markdown has a different structure than the original

{
    "type": "root",
    "children": [
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text"
                },
                {
                    "type": "emphasis",
                    "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

    Labels

    🐛 type/bugThis is a problem👍 phase/yesPost is accepted and can be worked on🙆 yes/confirmedThis is confirmed and ready to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions