From cd772284e174f5200df905edcc5203dce94a6d35 Mon Sep 17 00:00:00 2001 From: marston Date: Fri, 2 Aug 2024 12:52:04 -0400 Subject: [PATCH] fixing position on scrolling code --- gen/script.js | 31 ++++++++----------------------- gen/styles/global.css | 5 ++++- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/gen/script.js b/gen/script.js index f597b24..675f48e 100644 --- a/gen/script.js +++ b/gen/script.js @@ -22,29 +22,8 @@ function start() { for (const allPre of allPres) { const innerCodeBlocks = allPre.getElementsByTagName("code") - for (const innerCodeBlock of innerCodeBlocks) { - codeBlocks.push(innerCodeBlock) - } - - } - - const codes = [] - - for (const codeBlock of codeBlocks) { - console.log(codeBlock) - const code = codeBlock.innerText - console.log(code) - codes.push(code) - } - - console.log(codes) - - console.log("highlighting...") - hljs.highlightAll(); + const code = innerCodeBlocks[0].innerText - for (let i = 0; i < codeBlocks.length; i++) { - const codeBlock = codeBlocks[i] - const code = codes[i] const button = document.createElement("button") button.classList.add("copy-button") @@ -68,8 +47,14 @@ function start() { }, false) - codeBlock.appendChild(button) + allPre.appendChild(button) + } + console.log("highlighting...") + hljs.highlightAll(); + + + } \ No newline at end of file diff --git a/gen/styles/global.css b/gen/styles/global.css index 9bf2733..33cfd6f 100644 --- a/gen/styles/global.css +++ b/gen/styles/global.css @@ -167,10 +167,13 @@ li.dropdown.open > ul { code { font-weight: bold; +} + +pre { position: relative; } -code > button { +pre > button { position: absolute; top: 12px; right: 12px;