Makefile for Pandoc: Markdown to HTML

Step-by-Step descriptions of how to do things.

Makefile for Pandoc: Markdown to HTML

Postby peter_b » Sat Sep 30, 2017 2:22 am

This HowTo mainly consists of a Makefile that can be used to convert multiple Markdown (.md) textfiles to HTML using Pandoc (on Linux).
You simply create and edit Markdown textfiles and when you're ready to publish them on the web, tell "GNU make" to compile all of them to HTML:
Code: Select all
$ make

This is equivalent to "$ make all".

Here's the Makefile for this:

Code: Select all
PD = pandoc
SRC = $(wildcard *.md)
HTML = $(
OUT = ../

all: clean $(HTML)

        $(PD) -so $@ $<
        echo mv $@ $(OUT)$@

        rm -f *.html

It looks for "*.md" and then calls the "%.html" target rule which calls Pandoc for the Markdown source and then moves the resulting file to the directory defined in "$(OUT)".

Thanks to Niko Heikkilä's example code.
  • 0

User avatar
Posts: 302
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to HowTo's

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: Google [Bot] and 5 guests

Reputation System ©'