#!/usr/bin/env bash set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" OUTPUT_DIR="$REPO_ROOT/slides" # Find all markdown files with marp: true frontmatter SLIDES=() while IFS= read -r f; do SLIDES+=("$f") done < <(grep -rl "^marp: true" "$REPO_ROOT/docs" --include="*.md" --exclude-dir=superpowers 2>/dev/null || true) if [ ${#SLIDES[@]} -eq 0 ]; then echo "No marp presentations found in docs/." exit 0 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)..." # 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 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 ,
# then loads and runs mermaid.js from CDN.
inject_mermaid() {
local html_file="$1"
python3 - "$html_file" << 'PYEOF'
import sys
path = sys.argv[1]
snippet = """\
"""
with open(path, encoding='utf-8') as f:
content = f.read()
new_content = content.replace('