From 0c3d06d3f2a7caf6640d83db361f6de444d717dc Mon Sep 17 00:00:00 2001 From: Dave Tang Date: Tue, 23 Jun 2026 15:23:59 +0900 Subject: Copy-to-Clipboard Button --- scripts/setup.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/setup.sh b/scripts/setup.sh index d3d188e..ab24775 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -3,10 +3,11 @@ # # Run this script from your Apache document root: # cd /path/to/docroot -# bash setup-docsify.sh [--with-prism] +# bash setup-docsify.sh [--with-prism] [--with-copy-code] # # Options: -# --with-prism Also download Prism and enable syntax highlighting in index.html +# --with-prism Also download Prism and enable syntax highlighting in index.html +# --with-copy-code Also download the docsify-copy-code plugin (copy button on code blocks) set -euo pipefail @@ -14,11 +15,13 @@ set -euo pipefail # Use "4" for the latest 4.x release, or pin to a specific version e.g. "4.13.1" DOCSIFY_VERSION="4" PRISM=false +COPY_CODE=false # ── Argument parsing ──────────────────────────────────────────────────────────── for arg in "$@"; do case "$arg" in --with-prism) PRISM=true ;; + --with-copy-code) COPY_CODE=true ;; *) echo "Unknown option: $arg" >&2; exit 1 ;; esac done @@ -81,6 +84,12 @@ if [[ "$PRISM" == true ]]; then fetch "${CDN}/prismjs@1/components/prism-javascript.min.js" assets/js/prism-javascript.min.js fi +if [[ "$COPY_CODE" == true ]]; then + echo "" + echo " Downloading copy-to-clipboard plugin..." + fetch "${CDN}/docsify-copy-code@3/dist/docsify-copy-code.min.js" assets/js/docsify-copy-code.min.js +fi + # ── Step 3: index.html ────────────────────────────────────────────────────────── step "Step 3 — Creating index.html" @@ -112,6 +121,14 @@ step "Step 3 — Creating index.html" HTML_HEAD + if [[ "$COPY_CODE" == true ]]; then + cat << 'HTML_COPYCODE' + + + +HTML_COPYCODE + fi + if [[ "$PRISM" == true ]]; then cat << 'HTML_PRISM' @@ -191,3 +208,8 @@ if [[ "$PRISM" == true ]]; then echo -e "To add more languages, download additional prism-*.min.js files" echo -e "into assets/js/ and add their