diff --git a/samples/coffee/0.coffee b/samples/coffee/0.coffee new file mode 100644 index 0000000..ff3fb9c --- /dev/null +++ b/samples/coffee/0.coffee @@ -0,0 +1,71 @@ +document.addEventListener("DOMContentLoaded", () => + document.querySelectorAll("pre.msh .js-copy").forEach((copy) => + copy.addEventListener("click", (e) => + e.preventDefault() + + content = copy.nextElementSibling + range = document.createRange() + range.selectNode(content) + + window.getSelection().addRange(range) + + try + successful = document.execCommand("copy") + copy.innerHTML = "Copied!" + + setTimeout => + copy.innerHTML = "Copy" + , 1500 + + msg = successful ? "successful" : "unsuccessful" + console.log({ msg }) + + catch error + console.log("Oops, unable to copy...") + + window.getSelection().removeAllRanges() + ) + ) + + document.querySelectorAll("pre.msh code[data-language='html'] span.line").forEach((line) => + content = line.innerHTML + content = content.replaceAll(/(<(\/?))(.+?(?=>))(>)/g, "$1$3$4") + + line.innerHTML = content + pink = line.querySelector(".c2") + + if pink != null + content = pink.innerHTML.split(" ") + content = content.map((part, index) => + if index > 0 + if part.includes("=") + part = part.replaceAll(/(.+?)(".*)/g, "$1$2") + else + part = part.replaceAll(/(.*\S)/g, "$1") + part + ).join(" ") + pink.innerHTML = content + return + ) + + document.querySelectorAll("pre.msh code[data-language='css'] span.line").forEach((line) => + content = line.innerHTML + + if line.dataset.indent + content = content.split(/:/g).map((part, index) => + if index == 0 + part.replace(/(.*)/g, "$1") + else + part = part.replaceAll(/(\S.+?(?=\s|;))/g, "$1") + part = part.replaceAll(/(".+?(?=,|\s|;))/g, "$1") + part = part.replaceAll(/(url\(.+?(?=\s|;))/g, "$1") + part.replaceAll(/\((.+?(?=\)))/g, "($1") + ).join(":") + else + content = content.replaceAll(/(.+?(?=,|\s|{}))/g, "$1") + content = content.replaceAll(/((\.|:).+?(?=\s))/g, "$1") + + line.innerHTML = content + return + ) +) diff --git a/samples/css/0.css b/samples/css/0.css new file mode 100644 index 0000000..a12e179 --- /dev/null +++ b/samples/css/0.css @@ -0,0 +1,32 @@ +@import url(https://fonts.googleapis.com/css?family=Roboto:400); +@import url("chrome://communicator/skin/"); +@import 'custom.css' screen and (max-width: 768px); + +@font-face { + font-family: 'Galada-Regular'; + src: url('Galada-Regular.ttf'); + font-style: normal; + font-weight: 400; +} + +/* Applies to the entire body of the HTML document (except where overridden by more specific +selectors). */ +body { + margin: 25px; + background-color: rgb(240,240,240); + font-family: arial, sans-serif; + font-size: 14px; +} + +/* Applies to all