1
0
Fork 0
This repository has been archived on 2025-05-26. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Checkpoint-Golang/public/js/docs.js
2025-05-26 12:42:36 -05:00

1 line
No EOL
812 B
JavaScript

import{highlightElement}from"https://unpkg.com/@speed-highlight/core@1.2.7/dist/index.js";document.addEventListener("DOMContentLoaded",()=>{initSyntaxHighlighting()});async function initSyntaxHighlighting(){try{const e=document.querySelectorAll(".code-example pre code");e.forEach(e=>{let t="html";const s=e.closest(".code-example");if(s){const e=s.querySelector(".code-label");if(e){const n=e.textContent.trim().toLowerCase();n==="css"&&(t="css"),(n==="js"||n==="javascript")&&(t="js"),(n==="go"||n==="golang")&&(t="go"),n==="json"&&(t="json"),n==="http"&&(t="http")}}const n=document.createElement("div");n.className=`shj-lang-${t}`,n.textContent=e.textContent;const o=e.parentElement;o.parentNode.replaceChild(n,o),highlightElement(n,t)})}catch(e){console.warn("Syntax highlighting failed to initialize:",e)}}