diff --git a/.gitignore b/.gitignore index ebd4eaa..47619b4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,6 @@ package-lock.json resources/DecimalJs/ resources/DecimalJsLight/ resources/FontAwesomePro/ -resources/HighlightJS/ -resources/GliderJs/ resources/PlotlyJs/ # Compiled Stuff diff --git a/.gitmodules b/.gitmodules index d2ea5e0..2661c66 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "resources/SplideJs"] path = resources/SplideJs url = https://github.com/Splidejs/splide.git +[submodule "resources/HighlightJS"] + path = resources/HighlightJS + url = https://github.com/highlightjs/highlight.js.git diff --git a/commons/DOM/head.php b/commons/DOM/head.php index 48d861a..0771226 100644 --- a/commons/DOM/head.php +++ b/commons/DOM/head.php @@ -15,7 +15,7 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) { '); + echo(''); } if($enable_gallery) { echo(''); diff --git a/commons/DOM/scripts.php b/commons/DOM/scripts.php index 5623aa9..dae4bd3 100644 --- a/commons/DOM/scripts.php +++ b/commons/DOM/scripts.php @@ -10,8 +10,7 @@ if($enable_gallery) { } if($enable_code_highlight) { - echo(''); - echo(''); + echo(''); } ?> diff --git a/commons/composer.php b/commons/composer.php index 7d88abc..34d818d 100644 --- a/commons/composer.php +++ b/commons/composer.php @@ -776,7 +776,7 @@ class ComposerElement { } if($this->codeCopyable) { - $htmlCode .= '
'; + $htmlCode .= ''; } diff --git a/compile.bat b/compile.bat index 7aa7f47..79c1bb0 100644 --- a/compile.bat +++ b/compile.bat @@ -74,6 +74,23 @@ echo ^> resources\DecimalJsLight\2.5.1\decimal.mjs call "%~dp0node_modules\.bin\terser" decimal.mjs -c -m --toplevel -o decimal.min.mjs popd +:libs-highlightjs +echo Handling HighlightJS +pushd %CD% +cd %~dp0\resources\HighlightJS\ +echo ^> Clearing old files +del /Q /S /F highlight.js 2> nul 1> nul +del /Q /S /F highlight.min.js 2> nul 1> nul +echo ^> Installing dependencies +call npm install > nul +echo ^> Building for browsers +node tools/build.js -t browser sql php c cpp vbnet java yaml css scss bash ini python shell dockerfile cmake purebasic csharp 1> nul +echo ^> Moving final files +robocopy %CD%\build %CD% highlight.js highlight.min.js 1> nul +echo ^> Minifying used CSS files +call "%~dp0node_modules\.bin\sass" src/styles/atom-one-dark.css:src/styles/atom-one-dark.min.css -q --style compressed +popd + :libs-end goto end diff --git a/resources/HighlightJS b/resources/HighlightJS new file mode 160000 index 0000000..f47103d --- /dev/null +++ b/resources/HighlightJS @@ -0,0 +1 @@ +Subproject commit f47103d4f1ac1592c56904574d1fbf5bf2475605 diff --git a/resources/NibblePoker/js/nibblepoker-code.js b/resources/NibblePoker/js/nibblepoker-code.js index a9fdab2..1490843 100644 --- a/resources/NibblePoker/js/nibblepoker-code.js +++ b/resources/NibblePoker/js/nibblepoker-code.js @@ -1,31 +1,29 @@ -// Highlights the code blocks when included on a page. -// This command is separated in its own file since highlight.js isn't on every page and because I can't use JS -// in a script element without using an external .js file. -Array.from(document.getElementsByClassName("code")).forEach(eCodeContainer => { - let language = null; - - eCodeContainer.classList.forEach(cCodeContainer => { - if(cCodeContainer.startsWith("language-")) { - language = cCodeContainer; - } - }); - - if(language !== null) { - Array.from(eCodeContainer.children).forEach(eCodeLine => { - if(eCodeLine.classList.contains("code-line")) { - eCodeLine.classList.add(language); - hljs.highlightElement(eCodeLine); +document.addEventListener("DOMContentLoaded", () => { + // Highlights the code blocks when included on a page. + // This command is separated in its own file since highlight.js isn't on every page and because I can't use JS + // in a script element without using an external .js file. + Array.from(document.getElementsByClassName("code")).forEach(eCodeContainer => { + let language = null; + + eCodeContainer.classList.forEach(cCodeContainer => { + if(cCodeContainer.startsWith("language-")) { + language = cCodeContainer; } }); - } -}); + + if(language !== null) { + Array.from(eCodeContainer.children).forEach(eCodeLine => { + if(eCodeLine.classList.contains("code-line")) { + eCodeLine.classList.add(language); + hljs.highlightElement(eCodeLine); + } + }); + } + }); -// Adding the action to copy the code to elements with the "js-code-copy" class. -// The search works by searching the closest parent with the "code" class or that is a "code" element, and then -// reading each of its children with the "code-line" class. -document.addEventListener("DOMContentLoaded", () => { - //let codeCopyButtonCount = 0; - + // Adding the action to copy the code to elements with the "js-code-copy" class. + // The search works by searching the closest parent with the "code" class or that is a "code" element, and then + // reading each of its children with the "code-line" class. Array.from(document.getElementsByClassName("js-code-copy")).forEach(eCodeCopyButton => { let eParentCodeBlock = eCodeCopyButton; @@ -46,10 +44,8 @@ document.addEventListener("DOMContentLoaded", () => { eCodeCopyButton.onclick = function() { navigator.clipboard.writeText(code); }; + + eCodeCopyButton.hidden = false; } - - //codeCopyButtonCount++; }); - - //console.debug("Added code copying to " + codeCopyButtonCount + " button(s)"); }); \ No newline at end of file