generated from tarleb/lua-filter-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
95 lines (83 loc) · 2.57 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
# Name of the filter file, *with* `.lua` file extension.
FILTER_FILE := $(wildcard *.lua)
# Name of the filter, *without* `.lua` file extension
FILTER_NAME = $(patsubst %.lua,%,$(FILTER_FILE))
# Allow to use a different pandoc binary, e.g. when testing.
PANDOC ?= pandoc
# Allow to adjust the diff command if necessary
DIFF = diff
# Current version, i.e., the latest tag. Used to version the quarto
# extension.
VERSION = $(shell git tag --sort=-version:refname --merged | head -n1 | \
sed -e 's/^v//' | tr -d "\n")
ifeq "$(VERSION)" ""
VERSION = 0.0.0
endif
# Ensure that the `test` target is run each time it's called.
.PHONY: test
test: test-default test-no-citeproc test-refs-name test-section-level \
test-unnumbered-section test-minlevel
# Test that running the filter on the sample input document yields
# the expected output.
test-%: $(FILTER_FILE) test/input.md test/input-unnumbered-section.md \
test/test.yaml \
test/test-%.yaml
$(PANDOC) --defaults test/test.yaml --defaults test/test-$*.yaml | \
$(DIFF) test/expected-$*.native -
# Update files that contain the expected test output
.PHONY: update-expected update-%
update-expected: update-default update-no-citeproc update-refs-name \
update-section-level update-unnumbered-section update-minlevel
update-%: $(FILTER_FILE) \
test/input.md \
test/input-unnumbered-section.md \
test/test.yaml \
test/test-%.yaml
$(PANDOC) \
--defaults=test/test.yaml \
--defaults=test/test-$*.yaml \
--output=test/expected-$*.native
#
# Website
#
.PHONY: website
website: _site/index.html _site/$(FILTER_FILE)
_site/index.html: README.md test/input.md $(FILTER_FILE) .tools/docs.lua \
_site/output.md _site/style.css
@mkdir -p _site
$(PANDOC) \
--standalone \
--lua-filter=.tools/docs.lua \
--metadata=sample-file:test/input.md \
--metadata=result-file:_site/output.md \
--metadata=code-file:$(FILTER_FILE) \
--css=style.css \
--toc \
--output=$@ $<
_site/style.css:
@mkdir -p _site
curl \
--output $@ \
'https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.css'
_site/output.md: $(FILTER_FILE) test/input.md test/test.yaml
@mkdir -p _site
$(PANDOC) \
--defaults=test/test.yaml \
--to=markdown \
--output=$@
_site/$(FILTER_FILE): $(FILTER_FILE)
@mkdir -p _site
(cd _site && ln -sf ../$< $<)
#
# Release
#
.PHONY: release
release:
git commit --amend --message "Release $(FILTER_NAME) $(VERSION)"
git tag --sign v$(VERSION) --message "$(FILTER_NAME) $(VERSION)"
#
# Clean
#
.PHONY: clean
clean:
rm -f _site/output.md _site/index.html _site/style.css