Books/2026.05-SGH-02/latex/latex2epub.sh

34 lines
479 B
Bash
Executable File

#!/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"