forked from mlhubber/mlmodels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandoc.mk
113 lines (83 loc) · 2.63 KB
/
pandoc.mk
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
########################################################################
#
# Makefile template for Document Format Conversion - pandoc
#
# Copyright 2018 (c) [email protected]
#
# License: Creative Commons Attribution-ShareAlike 4.0 International.
#
########################################################################
########################################################################
# GLOBAL VARIABLES
#
# I think the geometry for LaTeX should be a4 rather than a4paper to
# work with newer LaTeX. Should only need lang which pandoc should
# underneath also set babel-lang but that does not seem to be working
# 20171230 (reference man page).
PANDOC_PDF_OPTIONS=-V urlcolor=cyan -V geometry=a4paper -V lang=british -V babel-lang=british --number-sections
PANDOC_TEX_OPTIONS=$(PANDOC_PDF_OPTIONS) --standalone
PANDOC_CSS=pandoc.css
PANDOC_HTML_OPTIONS=--standalone --self-contained
ifneq ("$(wildcard ../$(PANDOC_CSS))","")
PANDOC_HTML_OPTIONS := $(PANDOC_HTML_OPTIONS) --include-in-header=../$(PANDOC_CSS)
endif
ifneq ("$(wildcard $(PANDOC_CSS))","")
PANDOC_HTML_OPTIONS := $(PANDOC_HTML_OPTIONS) --include-in-header=$(PANDOC_CSS)
endif
########################################################################
# HELP
define PANDOC_HELP
Conversion of document formats using pandoc:
Inpute formats:
org Emacs org mode (the original).
rst Attempt to improve markdown.
md Mardown documents.
Output foramts:
txt Plain text file with duplicate empty lines removed.
md Markdown.
docx Microosft Word.
html
tex LaTeX.
pdf
view View the generated PDF document.
Example:
$ make README.view # Generate and display .pdf from .org.
Default conversion options:
PDF: $(PANDOC_PDF_OPTIONS)
TEX: $(PANDOC_TEX_OPTIONS)
HTML: $(PANDOC_HTML_OPTIONS)
endef
export PANDOC_HELP
help::
@echo "$$PANDOC_HELP"
########################################################################
# RULES
%.txt: %.rst
pandoc -t plain $< | perl -00pe0 > $@
%.txt: %.md
pandoc -t plain $< | perl -00pe0 $@
%.md: %.rst
pandoc $< -o $@
%.docx: %.org
pandoc $(PANDOC_PDF_OPTIONS) $< -o $@
%.html: %.org
pandoc -o $@ $<
%.html: %.rst
pandoc $(PANDOC_HTML_OPTIONS) -o $@ $<
ifneq ("$(HTML_MSG)","")
sed -i -e "s|</body>|$(HTML_MSG)\n</body>|g" $@
endif
%.html: %.md
pandoc $(PANDOC_HTML_OPTIONS) -o $@ $<
%.tex: %.org
pandoc $(PANDOC_TEX_OPTIONS) $< -o $@
%.tex: %.rst
pandoc $(PANDOC_TEX_OPTIONS) $< -o $@
%.pdf: %.org
pandoc $(PANDOC_PDF_OPTIONS) $< -o $@
%.pdf: %.rst
pandoc $(PANDOC_PDF_OPTIONS) $< -o $@
%.pdf: %.md
pandoc $(PANDOC_PDF_OPTIONS) $< -o $@
%.view: %.pdf
atril $<