From 590ace418d7b274b2f8be0482d00c563f2687df2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 18 Sep 2021 12:03:19 -0700 Subject: [PATCH] tools,doc: fix misrendering of consecutive JS blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/40146 Reviewed-By: Michaël Zasso Reviewed-By: Tobias Nießen Reviewed-By: Antoine du Hamel --- tools/doc/html.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/doc/html.mjs b/tools/doc/html.mjs index 4efe569d11f153..9eb8ef8f9b2f7e 100644 --- a/tools/doc/html.mjs +++ b/tools/doc/html.mjs @@ -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 = '
' +
               '