-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathMakefile
71 lines (61 loc) · 1.88 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
build: set-date
# Create output directory.
mkdir -p out
# Pre-process Markdown file to:
#
# - Wrap version/date in \date{}.
# - Uncomment embedded LaTeX code.
# - Delete lines meant for README.md only.
sed -e 's/^<!-- \(Version.*\) -->/\\date{\1}/' \
-e 's/<!-- :: *\(.*\) -->/\1/g' \
-e '/<!-- x -->/d' \
README.md > out/gitpr.md
# Convert Markdown to LaTeX.
pandoc --template=meta/template.tex -o out/gitpr.tmp.tex out/gitpr.md
# Post-process LaTeX output to:
#
# - Reduce header levels.
# - Prevent splitting of verbatim block between pages.
# - Use PNG format Creative Commons license logo.
# - Reduce size of Creative Commons license logo.
sed -e 's/\\section/\\title/' \
-e 's/\\subsection/\\section/' \
-e 's/\\subsubsection/\\subsection/' \
-e 's/\\begin{verbatim}/\\vspace{5pt}\\begin{minipage}{\\linewidth}&/' \
-e 's/\\end{verbatim}/&\\end{minipage}\\vspace{5pt}/' \
-e 's/ccby\.svg/ccby.png/' \
-e 's/\\includegraphics/&[scale=0.75]/' \
out/gitpr.tmp.tex > out/gitpr.tex
# Generate PDF.
pdflatex out/gitpr.tex
pdflatex out/gitpr.tex
mv gitpr.pdf out/
# Generate TXT:
#
# - Uncomment version/date.
# - Delete embedded LaTeX code.
# - Delete images.
# - Use (c) as copyright symbol.
# - Delete lines meant for README.md only.
sed -e 's/^<!-- \(Version.*\) -->/\1/' \
-e '/<!-- :: *\(.*\) -->/d' \
-e '/SHIELD_/d' \
-e '/DOWNLOAD_/d' \
-e '/CC BY 4.0 Logo/d' \
-e 's/©/(c)/' \
-e '/<!-- x -->/d' \
README.md > out/gitpr.txt
install-tools-mac:
brew cask install basictex
brew install pandoc
clean:
rm -rf out
rm -f *.aux *.log *.out *.toc
view: build
-xdg-open out/gitpr.pdf || open out/gitpr.pdf
-less out/gitpr.txt
set-date:
sed "/<!-- Version/ s/(\(.*\))/($$(date +'%Y-%m-%d'))/" \
README.md > README.tmp
mv README.tmp README.md
test: clean build view