When code blocks are nested within list items with CommonMark's 7-space (3+4=7) indentation rule, remark fails to recognize the code blocks and treats them as nested paragraphs in the list item rather than <code>.
This CommonMark playground example shows how CommonMark handles nested code blocks within list items with various indentations.
TL;DR: CommonMark recognizes 7-space indents as code blocks in single-digit ordered list items.
The parsed
remarkAST should be same as the result in the CommonMark playground.
The remark parser fails to recognize CommonMark's (3+4=7) indentation for code blocks within list items and treats them as nested paragraphs in the list item rather than <code>.
This Prettier playground example shows how remark stumbles on the 7-space indentation.
_(See https://github.com/prettier/prettier/issues/3459 for the initial discussion and additional examples.)_
Thanks for the issue and sorry for the late reply!
That’s definitely a bug. The code for lists is pretty big and bug prone. It could use a rewrite!
@wooorm @infotexture any fixes for this issue? I believe this is unresolved: This markdown:
## Then numbered lists:
1. First install the dependencies:
\`$ npm install\`
1. Bar **bold**
1. Fruits
1. Apple
1. Oranges
1. Lemons
1. Roman
1. Greek
Muiltiline
With \`code\`.
1. Spanish
Gets rendered as:
$ npm installcode. 1. SpanishThis fails to recognize the sublist under the Lemons list item.
This is unresolved but we are working on an alternative: https://github.com/remarkjs/remark/issues/439
Sweet; exciting stuff; I'll keep my eyes peeled! :D
Heya, just wanted to give an update about micromark, it’s sort-of a new motor that we’ll soon use in remark to parse markdown. It’s 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!)
Heya, just wanted to give an update about micromark, it’s sort-of a new motor that we’ll soon use in remark to parse markdown. It’s 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!)
That's wonderful news! Thanks a ton and we're super excited. :)
Sorry for the wait! I just wanted to share that there’s now a PR that solves this issue: https://github.com/remarkjs/remark/pull/536.
Sorry for the wait! I just wanted to share that there’s now a PR that solves this issue: #536.
Woot Woot Woot Woot! Wow that's really impressive; thanks a ton I'll share the news with the team!!!!
Nice to see a solution for this on the horizon. Thanks to @wooorm for following up. 🙏
This is now released in [email protected]
Most helpful comment
Heya, just wanted to give an update about micromark, it’s sort-of a new motor that we’ll soon use in remark to parse markdown. It’s 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!)