summaryrefslogtreecommitdiff
path: root/pandoc.mk
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2015-03-13 17:00:38 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2015-03-13 17:00:38 -0400
commit2cf47d8e34b03a2750673c3fdefa42106cd10873 (patch)
treef17cfc331e513a7acf399378f14524f372db084a /pandoc.mk
parent54f5f17fd392f0bce307858bf1b9f1ca75abc00b (diff)
downloadmakefile_templates-2cf47d8e34b03a2750673c3fdefa42106cd10873.tar.gz
makefile_templates-2cf47d8e34b03a2750673c3fdefa42106cd10873.zip
added file to process pandoc files
Diffstat (limited to 'pandoc.mk')
-rw-r--r--pandoc.mk104
1 files changed, 104 insertions, 0 deletions
diff --git a/pandoc.mk b/pandoc.mk
new file mode 100644
index 0000000..0dc1ecc
--- /dev/null
+++ b/pandoc.mk
@@ -0,0 +1,104 @@
+# -*- make -*-
+# (C) 2013 by Eugeniy Mikhailov, <evgmik@gmail.com>
+# Processing of pandoc files
+
+CLEAN_TARGETS += clean_md
+REAL_CLEAN_TARGETS += real_clean_md
+
+md_files = $(wildcard *.md)
+tex_from_md = $(md_files:%.md=%.tex)
+pdf_from_md = $(md_files:%.md=%.pdf)
+html_from_md = $(md_files:%.md=%.html)
+
+# to disable preprocessor use
+#PANDOC_PREPROCESSOR_CMD ?= cat
+#PANDOC_PREPROCESSOR_OPTIONS ?=
+
+# preprocessor on
+PANDOC_PREPROCESSOR_CMD ?= gpp
+PANDOC_PREPROCESSOR_OPTIONS ?= -U "" "" "(" "," ")" "(" ")" "\#" "\\" -M "<\#" "\n" " " " " "\n" "(" ")"
+PANDOC_PREPROCESSOR ?= $(PANDOC_PREPROCESSOR_CMD) $(PANDOC_PREPROCESSOR_OPTIONS)
+
+PANDOC_COMMON_OPTIONS ?= --standalone --smart
+PANDOC_HTML_OPTIONS ?= -s --css=./css_styles/evmik_pandoc.css --section-divs --toc
+PANDOC_TEX_OPTIONS ?=
+PANDOC_PDF_OPTIONS ?= --latex-engine=pdflatex
+PANDOC_CMD := pandoc
+PANDOC := $(PANDOC_CMD) $(PANDOC_COMMON_OPTIONS)
+
+html_md: $(html_from_md)
+
+pdf_tex: $(pdf_from_independent_tex)
+
+pdf_md: $(pdf_from_md)
+
+tex_md: $(tex_from_md)
+
+
+
+$(html_from_md): %.html : %.md $(md_fig_files) $(md_configs)
+ $(PANDOC_PREPROCESSOR) $< | $(PANDOC) -t html $(PANDOC_HTML_OPTIONS) -o $@
+
+$(tex_from_md): %.tex : %.md $(md_fig_files) $(md_configs)
+ $(PANDOC_PREPROCESSOR) $< | $(PANDOC) -t latex $(PANDOC_TEX_OPTIONS) -o $@
+
+$(pdf_from_md): %.pdf : %.md $(md_fig_files) $(md_configs)
+ $(PANDOC_PREPROCESSOR) $< | $(PANDOC) $(PANDOC_PDF_OPTIONS) -o $@
+
+
+dest_dir_md:
+ $(INSTALL) -d -m 0755 $(dest_dir)
+
+install_md_src: dest_dir_md install_md_fig_files
+ifneq ($(strip $(md_files)),)
+ $(INSTALL) -m 0644 $(html_from_md) $(dest_dir)/
+endif
+
+install_md_fig_files:
+ifneq ($(strip $(md_fig_files)),)
+ $(INSTALL) -m 0644 $(md_fig_files) $(dest_dir)/
+endif
+
+install_html_md: dest_dir_md $(html_from_md) install_md_fig_files
+ifneq ($(strip $(html_from_md)),)
+ $(INSTALL) -m 0644 $(html_from_md) $(dest_dir)/
+endif
+
+install_pdf_md: dest_dir_md $(pdf_from_md)
+ifneq ($(strip $(pdf_from_md)),)
+ $(INSTALL) -m 0644 $(pdf_from_md) $(dest_dir)/
+endif
+
+clean_md: clean_md_aux
+
+real_clean_md: clean_md_tex clean_md_aux
+ifneq ($(strip $(pdf_from_md)),)
+ rm -f $(pdf_from_md)
+endif
+ifneq ($(strip $(html_from_md)),)
+ rm -f $(html_from_md)
+endif
+
+clean_md_tex:
+ifneq ($(strip $(tex_from_md)),)
+ rm -f $(tex_from_md)
+endif
+
+clean_md_aux:
+ifneq ($(strip $(tex_from_md)),)
+ rm -f $(tex_from_md:%.tex=%.dvi)
+ rm -f $(tex_from_md:%.tex=%.log)
+ rm -f $(tex_from_md:%.tex=%.aux)
+ rm -f $(tex_from_md:%.tex=%.nav)
+ rm -f $(tex_from_md:%.tex=%.out)
+ rm -f $(tex_from_md:%.tex=%.snm)
+ rm -f $(tex_from_md:%.tex=%.toc)
+ rm -f $(tex_from_md:%.tex=%.vrb)
+ rm -f $(tex_from_md:%.tex=%.blg)
+ rm -f $(tex_from_md:%.tex=%.bbl)
+ rm -f missfont.log
+ rm -f *Notes.bib
+endif
+
+
+