Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emphasis with extra whitespace inside is parsed when it should not be #371

Closed
mariechatfield opened this issue Dec 2, 2019 · 1 comment
Labels
👀 no/external This makes more sense somewhere else

Comments

@mariechatfield
Copy link

mariechatfield commented Dec 2, 2019

According to the GitHub Flavored Markdown Spec, emphasis and strong emphasis should only be parsed when opened by a left-flanking delimiter run and closed by a right-flanking delimiter run, where:

  • a left-flanking delimiter run is not followed by Unicode whitespace
  • a right-flanking delimiter run is not preceded by Unicode whitespace

In Example 361, they show that a * foo bar* should not be parsed as emphasis since there is white-space between the opening asterisk and the text.

react-markdown is incorrectly parsing emphasis and strong emphasis with white space before and after the text.

react-markdown

| Sample                   | Should it parse? | Correct Behavior? |
|--------------------------|------------------|-------------------|
| __bold__                 | yes              | ✅                |
| __ starting space bold__ | no               | ❌                |
| __ending space bold __   | no               | ❌                |
| _italic_                 | yes              | ✅                |
| _ starting space italic_ | no               | ❌                |
| _ending space italic _   | no               | ❌                |

Screen Shot 2019-12-02 at 11 09 18 AM

GitHub

| Sample                   | Should it parse? | Correct Behavior? |
|--------------------------|------------------|-------------------|
| __bold__                 | yes              | ✅                |
| __ starting space bold__ | no               | ✅                |
| __ending space bold __   | no               | ✅                |
| _italic_                 | yes              | ✅                |
| _ starting space italic_ | no               | ✅                |
| _ending space italic _   | no               | ✅                |

Screen Shot 2019-12-02 at 11 08 22 AM

Workaround

It looks like setting parserOptions.pedantic prevents this behavior:

<ReactMarkdown parserOptions={{ pedantic: true }} />

But I'm fairly certain that React Markdown is meant to support GFM out of the box, so I think this is still a bug.

@ChristianMurphy
Copy link
Member

this is an upstream issue being tracked at remarkjs/remark#306 and will be resolved by remarkjs/remark#439

@ChristianMurphy ChristianMurphy added the 👀 no/external This makes more sense somewhere else label Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else
Development

No branches or pull requests

2 participants