-
Notifications
You must be signed in to change notification settings - Fork 6
/
formats.make
119 lines (87 loc) · 3.65 KB
/
formats.make
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
########################################################################
# Define output formats #
########################################################################
# document formats
html: $(NAME).html # first rule, so this is the default
tex: $(NAME).tex
pdf: $(NAME).pdf
epub: $(NAME).epub
epub3: $(NAME).epub3
rtf: $(NAME).rtf
odt: $(NAME).odt
docx: $(NAME).docx
# schema formats
bnf: $(NAME).bnf # Backus-Naur (TODO: which variant?)
ttl: $(NAME).ttl # RDF/Turtle
owl: $(NAME).owl # RDF/XML
rng: $(NAME).rng # RELAX NG
xsd: $(NAME).xsd # XML Schema
dtd: $(NAME).dtd # DTD
sch: $(NAME).sch # Schematron
sql: $(NAME).sql # SQL Schema
########################################################################
# Configure HTML document output format #
########################################################################
HTML_ARGS = --standalone --number-sections --section-divs --toc
HTML_TEMPLATE ?= $(MAKESPEC)/templates/default.html
HTML_CSS ?= $(MAKESPEC)/templates/default.css
HTML_VARS ?=
ifneq ($(HTML_TEMPLATE),)
HTML_ARGS += --template=$(HTML_TEMPLATE)
endif
ifneq ($(HTML_CSS),)
HTML_ARGS += --css=$(HTML_CSS)
endif
$(NAME).html: $(COMBINED) $(HTML_TEMPLATE) status
@echo "Creating $@..."
@$(PANDOC) $(HTML_ARGS) -f markdown -t html5 $(VARS) $(HTML_VARS) $(COMBINED) \
| perl -p -e 's!(http://[^<]+)\.</p>!<a href="$$1"><code class="url">$$1</code></a>.</p>!g' \
| perl -p -e 's!(<h2(.+)span>\s*([^<]+)</a></h2>)!<a id="$$3"></a>$$1!g' \
| sed 's!<td style="text-align: center;">!<td>!' > $@
########################################################################
# Configure LaTex and PDF document output formats #
########################################################################
TEX_ARGS = --standalone --number-sections --toc --latex-engine=xelatex
TEX_TEMPLATE ?= $(MAKESPEC)/templates/default.latex
TEX_VARS ?= -V documentclass=scrreprt -V "mainfont=DejaVu Serif"
ifneq ($(TEX_TEMPLATE),)
TEX_ARGS += --template=$(TEX_TEMPLATE)
endif
# TODO: $(BIBARGS) $(BIBLATEX) ...
$(NAME).tex: $(COMBINED) $(TEX_TEMPLATE) status
@echo "Creating $@..."
@$(PANDOC) $(TEX_ARGS) -f markdown -o $@ $(VARS) $(TEX_VARS) $(COMBINED)
$(NAME).pdf: $(COMBINED) $(TEX_TEMPLATE) status
@echo "Creating $@..."
@$(PANDOC) $(TEX_ARGS) -f markdown -o $@ $(VARS) $(TEX_VARS) $(COMBINED)
########################################################################
# Configure Epub/Epub2 document output formats #
########################################################################
EPUB_ARGS = --standalone --number-sections --toc
EPUB_TEMPLATE ?=
EPUB_CSS ?= $(MAKESPEC)/templates/default.epub.css
EPUB_VARS ?=
# TODO: use HTML_TEMPLATE by default?
ifneq ($(EPUB_TEMPLATE),)
EPUB_ARGS += --template=$(EPUB_TEMPLATE)
endif
ifneq ($(EPUB_CSS),)
EPUB_ARGS += --epub-stylesheet=$(EPUB_CSS)
endif
# TODO:
# --bibliography=$(REFERENCES)
# --epub-cover-image=
# --epub-embed-font=
# --epub-chapter-level=
$(NAME).epub: $(COMBINED)
@echo "Creating $@..."
@$(PANDOC) $(EPUB_ARGS) -f markdown -o $@ $(VARS) $(EPUB_VARS) $(COMBINED)
########################################################################
# Configure additional document output formats #
########################################################################
RTF_ARGS = --standalone --number-sections --toc
$(NAME).rtf: $(COMBINED)
@$(PANDOC) $(RTF_ARGS) -f markdown -o $@ $(COMBINED)
ODT_ARGS = --standalone --number-sections --toc
$(NAME).odt: $(COMBINED)
@$(PANDOC) $(ODT_ARGS) -f markdown -o $@ $(COMBINED)