#!/bin/bash set -e INPUT="$1" if [ -z "$INPUT" ]; then echo "Usage: $0 main.tex" exit 1 fi if [ ! -f "$INPUT" ]; then echo "ERROR: File not found: $INPUT" exit 1 fi BASENAME="${INPUT%.tex}" OUTPUT="${BASENAME}.epub" echo "Converting:" echo " $INPUT" echo "to:" echo " $OUTPUT" pandoc \ --from=latex \ --to=epub3 \ --metadata-file=epub.yaml \ --resource-path=".:$(dirname "$INPUT")" \ "$INPUT" \ -o "$OUTPUT" echo "Done: $OUTPUT"