summaryrefslogtreecommitdiff
path: root/pandoc.mk
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2015-03-14 15:30:22 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2015-03-14 15:30:22 -0400
commite68af4f2b78830123ca38f904ec058c81169296e (patch)
tree78a25b652322fd6fb192e05ad264f927a0f6b76f /pandoc.mk
parent5e6f037190eb203943287895374f89202d9eb29c (diff)
downloadmakefile_templates-e68af4f2b78830123ca38f904ec058c81169296e.tar.gz
makefile_templates-e68af4f2b78830123ca38f904ec058c81169296e.zip
improved pandoc makefile to be intelligent about template and css
Diffstat (limited to 'pandoc.mk')
-rw-r--r--pandoc.mk44
1 files changed, 38 insertions, 6 deletions
diff --git a/pandoc.mk b/pandoc.mk
index c3f5117..d5e85f2 100644
--- a/pandoc.mk
+++ b/pandoc.mk
@@ -19,17 +19,49 @@ PANDOC_PREPROCESSOR_CMD ?= gpp
PANDOC_PREPROCESSOR_OPTIONS ?= -U "" "" "(" "," ")" "(" ")" "\#" "\\" -M "<\#" "\n" " " " " "\n" "(" ")"
PANDOC_PREPROCESSOR ?= $(PANDOC_PREPROCESSOR_CMD) $(PANDOC_PREPROCESSOR_OPTIONS)
+PANDOC_CMD := pandoc
+PANDOC_COMMON_OPTIONS ?= --standalone --smart
+PANDOC := $(PANDOC_CMD) $(PANDOC_COMMON_OPTIONS)
+
+PANDOC_DATA_DIR ?= $(CONFIG_DIR)
+PANDOC_META_DIR ?= $(CONFIG_DIR)
+PANDOC_CSS_DIR ?= $(TOPDIR)/css_styles
+PANDOC_CSS ?=
+
+PANDOC_TEMPLATE ?=
+
+ifneq ($(strip $(PANDOC_DATA_DIR)),)
+ PANDOC += --data-dir=$(PANDOC_DATA_DIR)
+endif
+
+ifneq ($(strip $(PANDOC_TEMPLATE)),)
+ PANDOC += --template=$(PANDOC_TEMPLATE)
+endif
+
+# chose default name for css if it is not define
+ifeq ($(strip $(PANDOC_CSS)),)
+ ifneq ($(strip $(PANDOC_TEMPLATE)),)
+ # non empty template name
+ PANDOC_CSS = evmik_pandoc_$(PANDOC_TEMPLATE).css
+ else
+ # empty template name
+ #PANDOC_CSS = evmik_pandoc.css
+ PANDOC_CSS = evmik_pandoc_$(PANDOC_TEMPLATE).css
+ endif
+endif
+
+
PANDOC_HTML_METADATA ?= cat -
-PANDOC_TEX_METADATA ?= cat - $(CONFIG_DIR)/tex_metadata.yaml
+PANDOC_TEX_METADATA ?= cat - $(PANDOC_META_DIR)/tex_metadata.yaml
PANDOC_PDF_METADATA ?= $(PANDOC_TEX_METADATA)
-PANDOC_COMMON_OPTIONS ?= --standalone --smart
-PANDOC_HTML_OPTIONS ?= -s --css=$(TOPDIR)/css_styles/evmik_pandoc.css --section-divs --toc
+PANDOC_HTML_OPTIONS ?= -s --section-divs --toc
PANDOC_TEX_OPTIONS ?= --latex-engine=pdflatex
PANDOC_PDF_OPTIONS ?= --latex-engine=pdflatex
-PANDOC_CMD := pandoc
-PANDOC := $(PANDOC_CMD) $(PANDOC_COMMON_OPTIONS)
+ifneq ($(strip $(PANDOC_CSS)),)
+ PANDOC_HTML_OPTIONS += --css=$(PANDOC_CSS_DIR)/$(PANDOC_CSS)
+endif
html_md: $(html_from_md)
@@ -42,7 +74,7 @@ tex_md: $(tex_from_md)
$(html_from_md): %.html : %.md $(md_fig_files) $(md_configs)
- $(PANDOC_PREPROCESSOR) $< | $(PANDOC_HTML_METADATA) | $(PANDOC) -t html $(PANDOC_HTML_OPTIONS) -o $@
+ $(PANDOC_PREPROCESSOR) $< | $(PANDOC_HTML_METADATA) | $(PANDOC) -t html5 $(PANDOC_HTML_OPTIONS) -o $@
$(tex_from_md): %.tex : %.md $(md_fig_files) $(md_configs)
$(PANDOC_PREPROCESSOR) $< | $(PANDOC_TEX_METADATA) | $(PANDOC) -t latex $(PANDOC_TEX_OPTIONS) -o $@