forked from pandoc/dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
152 lines (129 loc) · 4.16 KB
/
Makefile
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
152
# Two primary targets are defined by this Makefile:
#
# 1. test-core: test a core base image
# 2. test-latex: test a latex image
#
# The IMAGE variable is required to be defined in order to `docker run` the
# various tests. The parent Makefile test targets define this, or alternatively
#
# 1. IMAGE=pandoc/image:tag make test-core
# 2. IMAGE=pandoc/image:tag make test-latex
ifndef IMAGE
$(error IMAGE variable must be set to docker image to test)
endif
test_files_path := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
.PHONY: test
test: test-core test-latex
# ____
# / ___|___ _ __ ___
# | | / _ \| '__/ _ \
# | |__| (_) | | | __/
# \____\___/|_| \___|
#
CORE_CMD = docker run --rm -it -v $(test_files_path):/data $(IMAGE)
OUTPUT_FORMATS=markdown epub docx latex html
.PHONY: test-core testsuite-to-% test-bib-conversion test-lua
test-core: test-bib-conversion test-lua \
$(foreach format,$(OUTPUT_FORMATS), testsuite-to-$(format))
testsuite-to-%: testsuite.native
@# Pure HTML cannot represent fractions, use supported math rendering method.
$(CORE_CMD) $< --output=/dev/null --to=$* --mathml
test-bib-conversion: example.bib
docker run --rm -it -v $(test_files_path):/data \
--entrypoint=/usr/bin/pandoc-citeproc $(IMAGE) \
--bib2yaml $< > /dev/null
test-lua: testsuite.native lpeg-test.lua
docker run --rm -it -v $(test_files_path):/data $(IMAGE) \
--lua-filter=lpeg-test.lua --to=json --output=/dev/null $<
# _ _____ __ __
# | | __ |_ _|__\ \/ /
# | | / _` || |/ _ \\ /
# | |__| (_| || | __// \
# |_____\__,_||_|\___/_/\_\
#
LATEX_CMD = docker run --rm -it \
-v $(test_files_path):/data \
$(IMAGE) \
--fail-if-warnings
# Generate list of targets to test all highlighting options available in pandoc.
# See: https://pandoc.org/MANUAL.html#option--highlight-style
styles = pygments \
kate \
monochrome \
breezeDark \
espresso \
zenburn \
haddock \
tango
# Create code-highlight-{pygments,kate,...}.pdf targets names. List needed now
# to add to test-latex target. Rules generated below after test-biblatex.pdf.
code_targets = $(addsuffix .pdf, $(addprefix output/code-highlight-, $(styles)))
.PHONY: test-latex
test-latex: output/testsuite.pdf output/french.pdf output/german.pdf \
output/lorem-geometry.pdf output/lorem-optional-packages.pdf \
output/test-beamer.pdf output/test-natbib.pdf output/test-biblatex.pdf \
$(code_targets)
output/testsuite.pdf: testsuite.native
$(LATEX_CMD) $< \
--output=$@ \
--pdf-engine=xelatex
output/french.pdf: french.md
$(LATEX_CMD) $< \
--output=$@ \
--pdf-engine=xelatex
output/german.pdf: german.md
$(LATEX_CMD) $< \
--output=$@ \
--pdf-engine=xelatex
output/lorem-geometry.pdf: lorem.md geometry.yaml
$(LATEX_CMD) $< \
--output=$@ \
--metadata-file=geometry.yaml \
--pdf-engine=xelatex
output/lorem-optional-packages.pdf: lorem.md optional-packages.yaml
$(LATEX_CMD) $< \
optional-packages.yaml \
--output=$@ \
--pdf-engine=xelatex
output/test-beamer.pdf: test-beamer.md example.bib
$(LATEX_CMD) $< \
--output=$@ \
--to=beamer \
--bibliography=example.bib \
--pdf-engine=xelatex
output/test-natbib.pdf: test-beamer.md example.bib
$(LATEX_CMD) $< \
--natbib \
--output=$@ \
--bibliography=example.bib \
--pdf-engine=xelatex
output/test-biblatex.tex: test-beamer.md
$(LATEX_CMD) $< \
--biblatex \
--standalone \
--bibliography=example.bib \
--output=$@
output/example.bib: example.bib
cp $< $@
output/baboon.png: baboon.png
cp $< $@
output/test-biblatex.pdf: output/test-biblatex.tex output/example.bib \
output/baboon.png
docker run --rm -it -v $(test_files_path):/data \
--entrypoint=/data/pdf-via-biblatex.sh \
$(IMAGE) \
$(notdir $(basename $<))
# Use every highlighter to make sure all needed packages are installed.
$(code_targets): output/code-highlight-%.pdf: code-highlight.md
$(LATEX_CMD) $< \
--highlight-style=$* \
--output=$@
# ____ _
# / ___| | ___ __ _ _ __
# | | | |/ _ \/ _` | '_ \
# | |___| | __/ (_| | | | |
# \____|_|\___|\__,_|_| |_|
#
.PHONY: clean
clean:
rm -rf output/*