Skip to content

doc: fix ES module code blocks rendering in modules.md#62181

Open
okuryu wants to merge 1 commit intonodejs:mainfrom
okuryu:fix/doc-modules-code-blocks
Open

doc: fix ES module code blocks rendering in modules.md#62181
okuryu wants to merge 1 commit intonodejs:mainfrom
okuryu:fix/doc-modules-code-blocks

Conversation

@okuryu
Copy link
Contributor

@okuryu okuryu commented Mar 10, 2026

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.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem. labels Mar 10, 2026
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.
@okuryu okuryu force-pushed the fix/doc-modules-code-blocks branch from dc4df4f to 77e597f Compare March 10, 2026 13:27
@Renegade334
Copy link
Member

Good spot, but this is actually a regression from the switch to the doc-kit legacy generator (cc @nodejs/web-infra)

@ovflowd
Copy link
Member

ovflowd commented Mar 10, 2026

This seems to be a well known bug on node-core/rehype-shiki I suppose? cc @avivkeller

@avivkeller
Copy link
Member

cc @AugustinMauroy is this that issue you were talking about a few months ago?

@ovflowd
Copy link
Member

ovflowd commented Mar 10, 2026

It is, yes!

@okuryu
Copy link
Contributor Author

okuryu commented Mar 11, 2026

This fix works fine as a workaround, but should we be fixing this in rehype-shiki instead?

@ovflowd
Copy link
Member

ovflowd commented Mar 11, 2026

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!!

@avivkeller
Copy link
Member

avivkeller commented Mar 11, 2026

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

@avivkeller
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants