1INPUTS = index.md concepts.md reference.md security.md migration.md whats_new.md
2
3all: $(INPUTS:.md=.html)
4
5tmp_menu.html: $(INPUTS)
6	echo '<div id="index">' > $@
7	(echo '<h2>Documentation index</h2>'; \
8	 for file in $^; do echo -n '1. ['; sed -n '1 s!^# Nanopb: !! p' $$file; \
9	 echo -n "]("; echo $$file | sed 's/.md/.html)/' ; done;) | \
10	 pandoc -f markdown -t html5 >> $@
11	echo '</div>' >> $@
12
13%.html: %.md tmp_menu.html
14	sed '1 s!#!%!' $< | \
15	pandoc -s -f markdown -t html5 -c lsr.css --toc --toc-depth=4 \
16	 --variable 'header-includes=<link href="favicon.ico" type="image/x-icon" rel="shortcut icon" />' \
17	 --indented-code-classes=c \
18	 -o $@
19	sed -i '/<nav/e cat feedback.html' $@
20	sed -i 's/doc_page_name_placeholder/$</' $@
21	sed -i 's!<nav[^>]*>!\0<b>Contents:</b>!' $@
22	sed -i '/<nav/e cat tmp_menu.html' $@
23
24