forked from DILCISBoard/E-ARK-SIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-pdf.sh
executable file
·100 lines (86 loc) · 3.71 KB
/
create-pdf.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
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
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR" || exit
echo "Generating PDF from markdown"
bash "$SCRIPT_DIR/spec-publisher/utils/create-venv.sh"
command -v markdown-pp >/dev/null 2>&1 || {
tmpdir=$(dirname "$(mktemp -u)")
# shellcheck source=/tmp/.venv-markdown/bin/activate
source "$tmpdir/.venv-markdown/bin/activate"
}
echo " - MARKDOWN-PP: Processing postface markdown"
cd "./specification/postface/" || exit
markdown-pp postface-pdf.md -o "$SCRIPT_DIR/docs/postface.md" -e tableofcontents
cd "$SCRIPT_DIR/docs" || exit
###
# Pandoc options:
# --from markdown \ # Source fromat Markdown
# --template ../pandoc/templates/eisvogel.latex \ # Use this latex template
# --listings \ # Use listings package for code blocks
# --table-of-contents \ # Generate table of contents
# --metadata-file ../pandoc/metadata.yaml \ # Additional Pandoc metadata
# --include-before-body "../spec-publisher/res/md/common-intro.md" \
# --include-after-body "../specification/postface/postface.md" \
# --number-sections \ # Generate Heading Numbers
# eark-csip-pdf.md \ # Input Markdown file
# -o ./pdf/eark-csip.pdf # PDF Destinaton
echo " - PANDOC: Generating Preface from markdown"
pandoc --from gfm \
--to latex \
--metadata-file "../spec-publisher/pandoc/metadata.yaml" \
"../spec-publisher/res/md/common-intro.md" \
-o ./preface.tex
sed -i 's%section{%section*{%' ./preface.tex
echo " - PANDOC: Generating Postface from markdown"
pandoc --from markdown \
--to latex \
--metadata-file "../spec-publisher/pandoc/metadata.yaml" \
"./postface.md" \
-o ./postface.tex
sed -i 's%section{%section*{%' ./postface.tex
rm postface.md
if [ ! -d "$SCRIPT_DIR/docs/pdf" ]
then
mkdir -p "$SCRIPT_DIR/docs/pdf/"
fi
cd "$SCRIPT_DIR" || exit
command -v markdown-pp >/dev/null 2>&1 || {
tmpdir=$(dirname "$(mktemp -u)")
# shellcheck source=/tmp/.venv-markdown/bin/activate
source "$tmpdir/.venv-markdown/bin/activate"
}
echo " - MARKDOWN-PP: Preparing PDF markdown"
markdown-pp PDF.md -o docs/eark-sip-pdf.md -e tableofcontents
cp -Rf specification/images docs/
cp -Rf spec-publisher/res/md/figs docs/
cd docs || exit
###
# Pandoc options:
# --from markdown \ # Source fromat Markdown
# --template ../pandoc/templates/eisvogel.latex \ # Use this latex template
# --listings \ # Use listings package for code blocks
# --table-of-contents \ # Generate table of contents
# --metadata-file ../pandoc/metadata.yaml \ # Additional Pandoc metadata
# --include-before-body "../spec-publisher/res/md/common-intro.md" \
# --include-after-body "../specification/postface/postface.md" \
# --number-sections \ # Generate Heading Numbers
# eark-sip-pdf.md \ # Input Markdown file
# -o ./pdf/eark-csip.pdf # PDF Destinaton
echo "PANDOC: Generating PDF document from markdown"
pandoc --from markdown \
--template "../spec-publisher/pandoc/templates/eisvogel.latex" \
--listings \
--table-of-contents \
--metadata-file "../spec-publisher/pandoc/metadata.yaml" \
--include-before-body "./preface.tex" \
--include-after-body "./postface.tex" \
--number-sections \
eark-sip-pdf.md \
-o "./pdf/eark-sip.pdf"
echo "PANDOC: Finished"
rm postface.tex preface.tex eark-sip-pdf.md
cd "$SCRIPT_DIR" || exit
# if [ -e docs/eark-csip-pdf.md ]
# then
# rm docs/eark-csip-pdf.md
# fi