From 5cd5a8782348ca4635da3bcb071a4e579115a499 Mon Sep 17 00:00:00 2001 From: Dave Gallant Date: Sun, 17 Dec 2023 22:07:35 -0500 Subject: [PATCH] Fix double spacing with copy command --- public/js/copy-code-button.js | 6 +++--- themes/archie/static/js/copy-code-button.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/js/copy-code-button.js b/public/js/copy-code-button.js index 5d92b2b2..ca1e5d77 100644 --- a/public/js/copy-code-button.js +++ b/public/js/copy-code-button.js @@ -19,9 +19,9 @@ document .forEach((highlightDiv) => createCopyButton(highlightDiv)); async function copyCodeToClipboard(button, highlightDiv) { - const codeToCopy = highlightDiv.querySelector( - "pre > code" - ).innerText; + const codeToCopy = highlightDiv + .querySelector("pre > code ") + .innerText.replace(/\n\n/g, "\n"); // This is needed to fix the double spacing try { var result = await navigator.permissions.query({ name: "clipboard-write" }); if (result.state == "granted" || result.state == "prompt") { diff --git a/themes/archie/static/js/copy-code-button.js b/themes/archie/static/js/copy-code-button.js index 5d92b2b2..ca1e5d77 100644 --- a/themes/archie/static/js/copy-code-button.js +++ b/themes/archie/static/js/copy-code-button.js @@ -19,9 +19,9 @@ document .forEach((highlightDiv) => createCopyButton(highlightDiv)); async function copyCodeToClipboard(button, highlightDiv) { - const codeToCopy = highlightDiv.querySelector( - "pre > code" - ).innerText; + const codeToCopy = highlightDiv + .querySelector("pre > code ") + .innerText.replace(/\n\n/g, "\n"); // This is needed to fix the double spacing try { var result = await navigator.permissions.query({ name: "clipboard-write" }); if (result.state == "granted" || result.state == "prompt") {