Skip to content

Markdown underscore matches inline code block content #7695

@joemaller

Description

@joemaller

Prettier 1.19.1
Playground link

--parser markdown

Input:

aa_bb `aa_bb`

aa_bb `aa _bb`

aa_bb `aa_ bb`

aa_bb `aa_`

Renders correctly:

aa_bb aa_bb

aa_bb aa _bb

aa_bb aa_ bb

aa_bb aa_

Output:

aa_bb `aa_bb`

aa_bb `aa _bb`

aa*bb `aa* bb`

aa*bb `aa*`

Renders incorrectly:

aa_bb aa_bb

aa_bb aa _bb

aa*bb aa* bb

aa*bb aa*

Expected behavior:

Code should be unchanged, asterisks should not replace underscores in prose. Underscores should not be matched to content inside an inline code block. Original input renders correctly on the commonmark dingus

This seems to have something to do with tokens inside the inline code block ending with an underscore.

Workaround

Adding a backslash to the initial underscore prevents the content from changing.

aa\_bb `aa_ bb`

aa\_bb `aa_`

Renders correctly:

aa_bb aa_ bb

aa_bb aa_

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:markdownIssues affecting Markdownscope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions