From e68af4f2b78830123ca38f904ec058c81169296e Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Sat, 14 Mar 2015 15:30:22 -0400 Subject: improved pandoc makefile to be intelligent about template and css --- pandoc.mk | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file 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 $@ -- cgit v1.2.3