Skip to content

Commit 590ace4

Browse files
TrottBethGriggs
authored andcommittedSep 21, 2021
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 <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent a07d844 commit 590ace4

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)
Please sign in to comment.