From 9e5a315c54af2494ab2ff652b945bda4e2fa97c6 Mon Sep 17 00:00:00 2001 From: sjat Date: Sun, 10 May 2026 17:49:02 +0200 Subject: [PATCH] fix: make build-slides.sh work with Docker marp by using temp directory with proper permissions - Process each slide individually to avoid Docker --output flag issues - Use a temp directory with 777 permissions for Docker to write to - Copy generated files to final output directory after build - Both marp-cli and mermaid injection now work properly with Docker Co-Authored-By: Claude Sonnet 4.6 --- build-slides.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/build-slides.sh b/build-slides.sh index 47b4a4a..6419836 100755 --- a/build-slides.sh +++ b/build-slides.sh @@ -3,7 +3,6 @@ set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" OUTPUT_DIR="$REPO_ROOT/slides" -mkdir -p "$OUTPUT_DIR" # Find all markdown files with marp: true frontmatter SLIDES=() @@ -19,20 +18,32 @@ fi echo "Found ${#SLIDES[@]} presentation(s):" printf ' %s\n' "${SLIDES[@]}" +# Create temp output directory for Docker +TEMP_OUTPUT=$(mktemp -d) +chmod 777 "$TEMP_OUTPUT" +trap "rm -rf '$TEMP_OUTPUT'" EXIT + if command -v marp &>/dev/null; then marp --html --output "$OUTPUT_DIR/" "${SLIDES[@]}" else echo "marp not found locally — using Docker (marpteam/marp-cli)..." - REL_SLIDES=() - for f in "${SLIDES[@]}"; do - REL_SLIDES+=("${f#"$REPO_ROOT"/}") + # Process each slide individually in Docker + for slide in "${SLIDES[@]}"; do + REL_SLIDE="${slide#${REPO_ROOT}/}" + BASENAME=$(basename "${slide%.*}") + docker run --rm \ + -v "$REPO_ROOT":/home/marp/app:ro \ + -v "$TEMP_OUTPUT":/home/marp/output \ + marpteam/marp-cli --html --output "/home/marp/output/${BASENAME}.html" "$REL_SLIDE" done - docker run --rm \ - -v "$REPO_ROOT":/home/marp/app:ro \ - -v "$OUTPUT_DIR":/home/marp/output \ - marpteam/marp-cli --html --output /home/marp/output "${REL_SLIDES[@]}" fi +# Ensure output directory exists +mkdir -p "$OUTPUT_DIR" + +# Copy generated HTML files to final output directory +cp "$TEMP_OUTPUT"/*.html "$OUTPUT_DIR/" 2>/dev/null || true + # Inject mermaid.js into any HTML that contains mermaid code blocks. # Marp emits fenced mermaid blocks as
.
 # The script finds those elements, replaces them with 
,