Skip to content

Commit b0d5eec

Browse files
Trottnodejs-github-bot
authored andcommitted
tools,doc: fix misrendering of consecutive JS blocks
Our markdown-to-html tool was assuming that any consecutive JS blocks were ESM vs CJS alternatives, but that is not always the case, resulting in both a confusing interface and invalid HTML. PR-URL: #40146 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 0bafe6d commit b0d5eec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/doc/html.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ export function preprocessElements({ filename }) {
227227
nextNode.lang !== node.lang) {
228228
// Saving the highlight code as value to be added in the next node.
229229
node.value = highlighted;
230-
} else if (isJSFlavorSnippet(previousNode)) {
230+
} else if (isJSFlavorSnippet(previousNode) &&
231+
previousNode.lang !== node.lang) {
231232
node.value = '<pre>' +
232233
'<input class="js-flavor-selector" type="checkbox"' +
233234
// If CJS comes in second, ESM should display by default.

0 commit comments

Comments
 (0)