Skip to content

Instantly share code, notes, and snippets.

@davidtsadler
Last active May 3, 2024 16:20
Show Gist options
  • Save davidtsadler/22511a16cb6df3bc56405f486e816de5 to your computer and use it in GitHub Desktop.
Save davidtsadler/22511a16cb6df3bc56405f486e816de5 to your computer and use it in GitHub Desktop.
Very simple script to that uses pandoc to convert a markdown file into a .mobi file that can be read on a Kindle.
#!/usr/bin/env bash
MD=$1
EPUB="${MD%.*}.epub"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <file name>."
exit 1
fi
if [ ! -f $MD ]; then
echo "[$MD] not found."
exit 1
fi
pandoc --toc $MD -o $EPUB
kindlegen $EPUB
rm $EPUB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment