doc: fix ES module code blocks rendering in modules.md#62181
doc: fix ES module code blocks rendering in modules.md#62181okuryu wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
The two consecutive `mjs` code blocks in the "Loading ECMAScript modules using require()" section were being incorrectly grouped into a CJS/ESM toggle tab by doc-kit's highlighter. Add text between the two code blocks so they render as independent code blocks.
dc4df4f to
77e597f
Compare
|
Good spot, but this is actually a regression from the switch to the doc-kit legacy generator (cc @nodejs/web-infra) |
|
This seems to be a well known bug on node-core/rehype-shiki I suppose? cc @avivkeller |
|
cc @AugustinMauroy is this that issue you were talking about a few months ago? |
|
It is, yes! |
|
This fix works fine as a workaround, but should we be fixing this in rehype-shiki instead? |
Yup, should be fixed there. Would you have bandwidth for making a contribution? xD -- although maybe my team would be more seasoned with the codebase, but you're welcome to try!! |
|
Actually, I think this is a separate bug. We don't actually use rehype-shiki's rehype plugin on the legacy generator, since it produces the new design. Thus, this is probably a bug with https://github.com/nodejs/doc-kit/blob/main/src/utils/highlighter.mjs |
|
It looks like, in that highlighter, we incorrectly assume that if a code block has two languages, it's a CJS/MJS pair https://github.com/nodejs/doc-kit/blob/main/src/utils/highlighter.mjs#L146 |
The two consecutive
mjscode blocks in the "Loading ECMAScript modules using require()" section were being incorrectly grouped into a CJS/ESM toggle tab by doc-kit's highlighter. Add text between the two code blocks so they render as independent code blocks.