Skip to content

Instantly share code, notes, and snippets.

@ratnanil
Created September 5, 2025 12:38
Show Gist options
  • Select an option

  • Save ratnanil/fa3c30045e0f47761ee82993d53ea7c9 to your computer and use it in GitHub Desktop.

Select an option

Save ratnanil/fa3c30045e0f47761ee82993d53ea7c9 to your computer and use it in GitHub Desktop.
A small script to export all revealjs slidedecks in qmd files to pdf. Requires quarto preview, a port number and export path
#!/bin/bash
# Convert .qmd file paths to localhost URLs with .html extension
# Check if port and export path are provided as arguments
if [ $# -lt 2 ]; then
echo "Usage: $0 <port> <export_path>"
exit 1
fi
PORT=$1
EXPORT_PATH=$2
BASE_URL="http://localhost:$PORT"
# Create export directory if it doesn't exist
mkdir -p "$EXPORT_PATH"
echo "Processing slide decks on port $PORT, exporting to: $EXPORT_PATH"
# Find all .qmd files not starting with underscore
find . -name "*.qmd" -not -name "_*" | while read -r qmd_file; do
# Remove ./ prefix and .qmd extension
clean_path=${qmd_file#./}
clean_path=${clean_path%.qmd}
# Convert to URL with .html extension
url="$BASE_URL/$clean_path.html"
# Get filename for PDF output
filename=$(basename "$clean_path")
pdf_output="$EXPORT_PATH/$filename.pdf"
echo "Processing: $url -> $pdf_output"
# Run decktape and wait for completion
if decktape reveal "$url" "$pdf_output"; then
echo "✓ Successfully exported $filename"
else
echo "✗ Failed to export $filename"
fi
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment