I had a problem converting embedded images and fonts from Markdown to EPUB; this script helps by piggy-backing on the epub-embed-font option to include images:
#!/bin/bash
FILENAME=$(cat title.txt).epub
CSS=style.css
IMAGES_DIR=images
# Ensure images get embedded into the document.
for url in $(grep image $CSS | grep url | sed 's/.*url( *\(.*\) *).*/\1/g'); do
EMBED="$EMBED --epub-embed-font=$IMAGES_DIR/$url"
done
# Generate the ePub, including fonts and images.
pandoc \
--smart \
--epub-cover-image=cover/cover.png \
--epub-metadata=metadata.xml \
--epub-stylesheet=$CSS \
--epub-embed-font=fonts/MyUnderwood.ttf \
$EMBED \
-t epub -o $FILENAME output/*.vars
The .vars files are chapters that have their variable names substituted for values, such as:
for i in chapter/*.md; do
out=$OUTDIR/$(basename $i);
cat variables.yaml $i > $out;
pandoc $out --template $out > $out.vars
cat $out.vars | sed -e 's/;;/\$/g' |\
pandoc --chapters -t context -o $OUTDIR/$(basename $i .md).tex;
done
A handy trick to avoid duplication (of names, places, or any text really) within the content.