mdast-util-from-markdown icon indicating copy to clipboard operation
mdast-util-from-markdown copied to clipboard

Parser confusion with nested emphasis suffixed with star

Open ChristianMurphy opened this issue 4 years ago • 2 comments

Subject of the issue

***a*a*a* a*

is parsed as

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

while in CommonMark it parses as

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="http://commonmark.org/xml/1.0">
  <paragraph>
    <emph>
      <emph>
        <emph>
          <text>a</text>
        </emph>
        <text>a</text>
      </emph>
      <text>a</text>
    </emph>
    <text> a</text>
    <text>*</text>
  </paragraph>
</document>

Not the difference in the depth of emphasis two vs three.

Your environment

  • OS: Ubuntu
  • Packages: mdast-util-from-markdown 0.8.5
  • Env: node v15.5.1

Steps to reproduce

const parse = require("mdast-util-from-markdown");

parse("***a*a*a* a*")

Expected behavior

Three levels of emphasis

Actual behavior

Two levels of emphasis

ChristianMurphy avatar Feb 05 '21 02:02 ChristianMurphy

Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved.

Is this something you can and want to work on?

Team: please use the area/* (to describe the scope of the change), platform/* (if this is related to a specific one), and semver/* and type/* labels to annotate this. If this is first-timers friendly, add good first issue and if this could use help, add help wanted.

github-actions[bot] avatar Aug 21 '21 15:08 github-actions[bot]

Another same/similar example: https://github.com/unifiedjs/unified/discussions/160#discussioncomment-1379260

wooorm avatar Sep 24 '21 10:09 wooorm