1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# -*- make -*-
# (C) 2013 by Eugeniy Mikhailov, <evgmik@gmail.com>
# Processing of pandoc files
CLEAN_TARGETS += clean_md
REAL_CLEAN_TARGETS += real_clean_md
dest_dir_md ?= $(dest_dir)
destination_dirs += $(dest_dir_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)
md_src_dest_targets = $(md_files:%=$(dest_dir_md)/%)
md_fig_dest_targets = $(md_fig_files:%=$(dest_dir_md)/%)
tex_from_md_dest_targets = $(tex_from_md:%=$(dest_dir_md)/%)
pdf_from_md_dest_targets = $(pdf_from_md:%=$(dest_dir_md)/%)
html_from_md_dest_targets = $(html_from_md:%=$(dest_dir_md)/%)
# 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_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 - $(PANDOC_META_DIR)/tex_metadata.yaml
PANDOC_PDF_METADATA ?= $(PANDOC_TEX_METADATA)
PANDOC_HTML_OPTIONS ?= --section-divs --toc
PANDOC_TEX_OPTIONS ?= --latex-engine=pdflatex
PANDOC_PDF_OPTIONS ?= --latex-engine=pdflatex
ifneq ($(strip $(PANDOC_CSS)),)
PANDOC_HTML_OPTIONS += --css=$(PANDOC_CSS_DIR)/$(PANDOC_CSS)
endif
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) $(md_includes)
$(PANDOC_PREPROCESSOR) $< | $(PANDOC_HTML_METADATA) | $(PANDOC) -t html5 $(PANDOC_HTML_OPTIONS) -o $@
$(tex_from_md): %.tex : %.md $(md_fig_files) $(md_configs) $(md_includes)
$(PANDOC_PREPROCESSOR) $< | $(PANDOC_TEX_METADATA) | $(PANDOC) -t latex $(PANDOC_TEX_OPTIONS) -o $@
$(pdf_from_md): %.pdf : %.md $(md_fig_files) $(md_configs) $(md_includes)
$(PANDOC_PREPROCESSOR) $< | $(PANDOC_PDF_METADATA) | $(PANDOC) $(PANDOC_PDF_OPTIONS) -o $@
install_md_src: $(md_src_dest_targets) install_md_fig_files
$(md_src_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md)
ifneq ($(strip $(md_files)),)
$(INSTALL) -m 0644 '$<' '$@'
endif
install_md_fig_files: $(md_fig_dest_targets)
$(md_fig_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md)
ifneq ($(strip $(md_fig_files)),)
$(INSTALL) -m 0644 '$<' '$@'
endif
install_html_md: $(html_from_md_dest_targets) install_md_fig_files
$(html_from_md_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md)
ifneq ($(strip $(html_from_md)),)
$(INSTALL) -m 0644 '$<' '$@'
endif
install_pdf_md: $(pdf_from_md_dest_targets)
$(pdf_from_md_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md)
ifneq ($(strip $(pdf_from_md)),)
$(INSTALL) -m 0644 '$<' '$@'
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
|