Remark: Inline code incorrectly parsed as emphasis in specific cases

Created on 12 May 2020  路  5Comments  路  Source: remarkjs/remark

Subject of the issue

remark incorrectly parses emphasis markers that span an inline code fence in certain cases.

https://astexplorer.net/#/gist/07d9ecadf011d35e45b47e73ff91edf8/1dc9657f969f4723440e250bcbf0c2b6e441d1ea

aa_bb `aa_ bb` parses _bb `aa_ as a single emphasis block instead of respecting the inline code marker.

aa_bb `aa _bb` is parsed correctly with no emphasis.

Relatedly, aa**bb `aa**bb` is also incorrectly parsed in a similar way. My suspicion is that these would be related bugs, but I can open a separate issue if not.

I haven't looked into where I think this is being caused but I'll take a look later today and see if I can't uncover it.

Steps to reproduce

See the astexplorer example from above: https://astexplorer.net/#/gist/07d9ecadf011d35e45b47e73ff91edf8/1dc9657f969f4723440e250bcbf0c2b6e441d1ea

Run aa_bb `aa_ bb` through the parser.

Expected behaviour

You should receive the following pseudo-AST:

text: "aa_bb"
inlineCode: "aa_ bb"

Actual behaviour

You receive the following psudo-AST:

text: "aa"
emphasis: "bb `aa"
text: "bb"

Relates to https://github.com/prettier/prettier/issues/7695

remark-parse 鉀碉笍 statureleased 馃悰 typbug 馃梽 areinterface

Most helpful comment

Sorry for the wait! I just wanted to share that there鈥檚 now a PR that solves this issue: https://github.com/remarkjs/remark/pull/536.

All 5 comments

Thanks for reporting this @saramarcondes n please keep on reporting anything you find, and great that remark in prettier is getting an upgrade!

I'm currently hard at work again working on a new markdown parser under remark, micromark, which still has lots more to do, but does include this fix!

@wooorm Thanks for letting me know! I look forward to updating prettier again when micromark is ready 馃榿 Thanks for all the hard work!

Heya, just wanted to give an update about micromark, it鈥檚 sort-of a new motor that we鈥檒l soon use in remark to parse markdown. It鈥檚 not yet 100% ready but will be relatively soon. The good news is, it fixes this issue! (P.S. see this twitter thread for some more info!)

Sorry for the wait! I just wanted to share that there鈥檚 now a PR that solves this issue: https://github.com/remarkjs/remark/pull/536.

This is now released in [email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maximbaz picture maximbaz  路  7Comments

kentcdodds picture kentcdodds  路  4Comments

rauschma picture rauschma  路  4Comments

ryanpcmcquen picture ryanpcmcquen  路  4Comments

muescha picture muescha  路  6Comments