forked from Meeds-io/whitepaper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·50 lines (37 loc) · 1.19 KB
/
build.sh
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
#!/bin/sh
## Usage : ./build.sh [lang]
## - lang : the 2-characters code for the language (default: en)
## get language from first arg
LANG=en
if [ "$1" ]; then
LANG=$1
fi
## source (english) content located under en/
CONTENT_PATH=./en
if [ "$LANG" != "en" ]; then
## translated content below content/intl/
CONTENT_PATH=./intl/$LANG
fi
YAML=$CONTENT_PATH/title.yml
if [[ -f "$YAML" ]]; then
echo "Pandoc Metadata loaded from $YAML"
## workaround Crowdin stripping out ... at end of yaml
LL=`tail -n 1 $YAML`
if [ "$LL" != "..." ]; then
echo "\n..." >> $YAML
echo "WARN : Detected and fixed missing ... at the end of $YAML."
fi
else
echo "WARN : Pandoc Metadata missing at $YAML"
fi
## cleanup output folder
mkdir -p build
rm -rf ./build/*
OUTPUT=build/meeds-whitepaper-$LANG.pdf
MDOWN=$CONTENT_PATH/*.md
echo "Processing markdown files from $MDOWN"
## transform all markdown fragments in content folder to pdf using eisvogel LateX template
pandoc --pdf-engine=xelatex -f markdown+smart -o $OUTPUT --top-level-division=chapter --template=templates/eisvogel.tex --toc -s $YAML $MDOWN
if [[ -f "$OUTPUT" ]]; then
echo "PDF generated at $OUTPUT".
fi