Skip to content

Commit

Permalink
tools,doc: fix misrendering of consecutive JS blocks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and BethGriggs committed Sep 21, 2021
1 parent a07d844 commit 590ace4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/doc/html.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ export function preprocessElements({ filename }) {
nextNode.lang !== node.lang) {
// Saving the highlight code as value to be added in the next node.
node.value = highlighted;
} else if (isJSFlavorSnippet(previousNode)) {
} else if (isJSFlavorSnippet(previousNode) &&
previousNode.lang !== node.lang) {
node.value = '<pre>' +
'<input class="js-flavor-selector" type="checkbox"' +
// If CJS comes in second, ESM should display by default.
Expand Down

0 comments on commit 590ace4

Please sign in to comment.