#!/usr/bin/env bash # Render a mermaid diagram to SVG using mmdc with sandbox/GPU workarounds # for Ubuntu 24.04+ (AppArmor restrictions). # # Usage: scripts/mermaid.sh input.mmd [output.svg] # scripts/mermaid.sh input.mmd - # output to stdout set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" CONFIG="$REPO_ROOT/puppeteer.config.json" if [[ $# -lt 1 ]]; then echo "Usage: $0 [output.svg|-]" >&2 exit 1 fi INPUT="$1" shift ARGS=("-i" "$INPUT" "-p" "$CONFIG") if [[ $# -gt 0 ]]; then OUTPUT="$1" shift ARGS+=("-o" "$OUTPUT") fi ARGS+=("$@") exec mmdc "${ARGS[@]}"