forked from pandoc-scholar/pandoc-scholar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (85 loc) · 3.68 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
## The path to the directory in which this file resides. This allows users to
## include this Makefile into theirs and to reuse all rules, given that they set
## this variable to the correct value.
PANDOC_SCHOLAR_PATH ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# include local makefile to allow easy overwriting of variables
-include local.mk
include $(PANDOC_SCHOLAR_PATH)/pandoc-options.inc.mk
LUA_FILTERS_PATH ?= $(PANDOC_SCHOLAR_PATH)/lua-filters
# Configuration (overwrite using Makefile.local.in if necessary)
ARTICLE_FILE ?= example/article.md
OUTFILE_PREFIX ?= outfile
DEFAULT_EXTENSIONS ?= latex pdf docx odt epub html
JSON_FILE ?= $(OUTFILE_PREFIX).enriched.json
FLATTENED_JSON_FILE ?= $(OUTFILE_PREFIX).flattened.json
LUA_FILTERS ?= $(LUA_FILTERS_PATH)/cito/cito.lua \
$(LUA_FILTERS_PATH)/abstract-to-meta/abstract-to-meta.lua \
$(LUA_FILTERS_PATH)/scholarly-metadata/scholarly-metadata.lua
all: $(addprefix $(OUTFILE_PREFIX).,$(DEFAULT_EXTENSIONS))
$(JSON_FILE): $(ARTICLE_FILE) $(LUA_FILTERS)
pandoc $(PANDOC_READER_OPTIONS) \
$(foreach filter, $(LUA_FILTERS), --lua-filter=$(filter)) \
--to=json \
--output=$@ $<
$(OUTFILE_PREFIX).pdf $(OUTFILE_PREFIX).latex: \
$(JSON_FILE) \
$(TEMPLATE_FILE_LATEX) \
$(PANDOC_SCHOLAR_PATH)/scholar-filters/template-helper.lua
pandoc $(PANDOC_WRITER_OPTIONS) \
$(PANDOC_LATEX_OPTIONS) \
--lua-filter=$(PANDOC_SCHOLAR_PATH)/scholar-filters/template-helper.lua \
--output $@ $<
$(OUTFILE_PREFIX).docx: $(JSON_FILE) \
$(ODT_REFERENCE_FILE) \
$(LUA_FILTERS_PATH)/author-info-blocks/author-info-blocks.lua
pandoc $(PANDOC_WRITER_OPTIONS) \
$(PANDOC_DOCX_OPTIONS) \
--lua-filter=$(LUA_FILTERS_PATH)/author-info-blocks/author-info-blocks.lua \
--output $@ $<
$(OUTFILE_PREFIX).odt: $(JSON_FILE) \
$(ODT_REFERENCE_FILE) \
$(LUA_FILTERS_PATH)/author-info-blocks/author-info-blocks.lua
pandoc $(PANDOC_WRITER_OPTIONS) \
$(PANDOC_ODT_OPTIONS) \
--lua-filter=$(LUA_FILTERS_PATH)/author-info-blocks/author-info-blocks.lua \
--output $@ $<
$(OUTFILE_PREFIX).epub: $(JSON_FILE) \
$(TEMPLATE_FILE_EPUB) \
$(LUA_FILTERS_PATH)/author-info-blocks/author-info-blocks.lua
pandoc $(PANDOC_WRITER_OPTIONS) \
$(PANDOC_EPUB_OPTIONS) \
--lua-filter=$(LUA_FILTERS_PATH)/author-info-blocks/author-info-blocks.lua \
--output $@ $<
$(OUTFILE_PREFIX).html: $(JSON_FILE) \
$(TEMPLATE_FILE_HTML) \
$(TEMPLATE_STYLE_HTML) \
$(PANDOC_SCHOLAR_PATH)/scholar-filters/template-helper.lua
pandoc $(PANDOC_WRITER_OPTIONS) \
$(PANDOC_HTML_OPTIONS) \
--lua-filter=$(PANDOC_SCHOLAR_PATH)/scholar-filters/template-helper.lua \
--css=$(TEMPLATE_STYLE_HTML) \
--self-contained \
--mathjax \
--output $@ $<
$(OUTFILE_PREFIX).jsonld: $(JSON_FILE) \
$(BIBLIOGRAPHY_FILE) \
$(PANDOC_SCHOLAR_PATH)/scholar-filters/json-ld.lua \
$(PANDOC_SCHOLAR_PATH)/writers/jsonld.lua
pandoc --to $(PANDOC_SCHOLAR_PATH)/writers/jsonld.lua \
--metadata "bibliography:$(BIBLIOGRAPHY_FILE)" \
--lua-filter=$(PANDOC_SCHOLAR_PATH)/scholar-filters/json-ld.lua \
--output=$@ $<
$(OUTFILE_PREFIX).txt: $(ARTICLE_FILE)
pandoc $(PANDOC_WRITER_OPTIONS) \
--output $@ $<
## Advanced JATS support is temporarily disabled.
$(OUTFILE_PREFIX).jats: $(JSON_FILE)
pandoc $(PANDOC_WRITER_OPTIONS) \
$(PANDOC_JATS_OPTIONS) \
--output $@ $<
clean:
rm -f $(OUTFILE_PREFIX).*
.PHONY: all clean
# Include archive-generating targets. This makefile is not included in the
# distributed archives
-include archives.inc.mk