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 <noreply@anthropic.com>
This commit is contained in:
parent
c6052a8a66
commit
9e5a315c54
1 changed files with 19 additions and 8 deletions
|
|
@ -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"/}")
|
||||
done
|
||||
# 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 "$OUTPUT_DIR":/home/marp/output \
|
||||
marpteam/marp-cli --html --output /home/marp/output "${REL_SLIDES[@]}"
|
||||
-v "$TEMP_OUTPUT":/home/marp/output \
|
||||
marpteam/marp-cli --html --output "/home/marp/output/${BASENAME}.html" "$REL_SLIDE"
|
||||
done
|
||||
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 <pre><code class="language-mermaid">.
|
||||
# The script finds those elements, replaces them with <div class="mermaid">,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue