Skip to content

Commit

Permalink
fix: compitable with mdbook hideline feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MR-Addict committed Apr 7, 2024
1 parent b4a5b5d commit 2dcf42b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/assets/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const id = replElement.getAttribute("data-id");
const lang = replElement.getAttribute("data-lang");
const code = replElement.nextElementSibling.innerText.trim();
const code = getCode(replElement.nextElementSibling);
const readonly = replElement.getAttribute("data-readonly") === "true";
let theme = mapTheme(localStorage.getItem("mdbook-theme") || "light");

Expand All @@ -15,6 +15,13 @@
return bookTheme === "light" || bookTheme === "rust" ? "light" : "dark";
}

function getCode(element) {
// remove all the boring elements
const code = element.cloneNode(true);
code.querySelectorAll(".boring").forEach((boring) => boring.remove());
return code.innerText.trim();
}

window.addEventListener("message", (event) => {
const repl = event.data.repl;
if (event.source === window || !repl) return;
Expand Down

0 comments on commit 2dcf42b

Please sign in to comment.