From e7360f31f28c94ddae167d741dde9df48ec4dca1 Mon Sep 17 00:00:00 2001 From: aslowwriter Date: Wed, 29 Apr 2026 12:09:02 +0200 Subject: [PATCH] Avoid copying code line numbers the copy code button would include line numbers, which is not good. This change removes them from the copied text by removing elements with the `.giallo-ln` class. --- static/js/copyCodeToClipboard.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/static/js/copyCodeToClipboard.js b/static/js/copyCodeToClipboard.js index 805eb59a..e550cae2 100644 --- a/static/js/copyCodeToClipboard.js +++ b/static/js/copyCodeToClipboard.js @@ -27,7 +27,13 @@ const copyCodeAndChangeIcon = async (copyDiv, block) => { }; const getNonTableCode = (block) => { - return [...block.querySelectorAll('code')].map((code) => code.textContent).join(''); + return [...block.querySelectorAll('code')] + .map((code) => { + const clone = code.cloneNode(true); + clone.querySelectorAll('.giallo-ln').forEach(el => el.remove()); + return clone.textContent; + }) + .join(''); }; const getTableCode = (block) => {