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.
  • Loading branch information
Trott committed Sep 18, 2021
1 parent 2b080cb commit 206c8bf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/doc/html.mjs
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 206c8bf

Please sign in to comment.