Creating ebook with Markdown, pandoc and GNU Make

Writing bok with markdown is pure joy. I started a short practical SQL tutorial yesterday and it started do get traction today. I used shell script at first to generate the static HTML page for the book but make looked like a better idea. Here is the Makefile I use:


BUILDDIR = ./build

.PHONY: clean spell

all:    html epub

html: *.markdown style.css Makefile
    pandoc -s --css=style.css --toc -o $(BUILDDIR)/index.html *.markdown
    cp style.css $(BUILDDIR)

epub: *.markdown style.css Makefile
    pandoc -t epub --epub-metadata=metadata.xml -s --epub-stylesheet=style.css --toc -o $(BUILDDIR)/book.epub *.markdown

clean:
    rm -f $(BUILDDIR)/*.html
    rm -f $(BUILDDIR)/*.css
    rm -f $(BUILDDIR)/*.epub
    rm -f *.bak

spell:
    for i in *.markdown; do aspell --lang=bg_BG check $$i; done

Important note: make requires TAB for indentation.

Comments

comments powered by Disqus