-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgenerate_slides.sh
More file actions
executable file
·115 lines (102 loc) · 2.67 KB
/
Copy pathgenerate_slides.sh
File metadata and controls
executable file
·115 lines (102 loc) · 2.67 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
SOURCE_FMT="markdown_strict\
+simple_tables\
+pipe_tables\
+backtick_code_blocks\
+auto_identifiers\
+strikeout\
+yaml_metadata_block\
+implicit_figures\
+all_symbols_escapable\
+link_attributes\
+smart\
+fenced_divs"
# Assumes the input is in the format: 'Chapter_NN_Title/cNN_name.md'
function __get_default_output_name() {
FILENAME="$(basename $(basename "$1") ".md")"
echo "${FILENAME}.pdf"
}
function generate_chapter_slides() {
local OUTPUT
local S_FMT
local TEMPLATE
local INPUT
while [[ $# > 0 ]]
do
case "$1" in
-o|--output)
OUTPUT="$2"
shift
shift
;;
-f|--source-fmt)
S_FMT="$2"
shift
shift
;;
-t|--template)
TEMPLATE="$2"
shift
shift
;;
-i|--input)
INPUT="$2"
shift
shift
;;
--*|-*)
echo "Unknown option: $1"
return 1
;;
*)
echo "Unexpected input: '$1'"
return 1
;;
esac
done
OUTPUT="${OUTPUT:-"build/$(__get_default_output_name "${INPUT}")"}"
S_FMT="${S_FMT:-"${SOURCE_FMT}"}"
TEMPLATE="${TEMPLATE:-"pandoc/templates/default_mod.latex"}"
OUTPUT_DIR="$(dirname "${OUTPUT}")"
if [ ! -d "$OUTPUT_DIR" ]
then
echo "Creating output directory: ${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}"
fi
pandoc -s \
--verbose \
--output="${OUTPUT}" \
--slide-level 2 \
--shift-heading-level=-1 \
--listings \
--toc \
--columns=50 \
-f "${S_FMT}" \
--template "${TEMPLATE}" \
--pdf-engine lualatex \
-t beamer \
--from=markdown+rebase_relative_paths \
"${INPUT}"
}
ALL_MD_FILES=($(find ./Chapter* -iname "*.md"))
CUSTOM_OPTS=("./Chapter_01_Introduction/c01_training_common.md|--template "pandoc/templates/default_mod_old.latex"")
for CUSTOM in "${CUSTOM_OPTS[@]}"
do
FILE="$(echo "${CUSTOM}" | cut -d '|' -f 1)"
OPTS="$(echo "${CUSTOM}" | cut -d '|' -f 2)"
echo "file with custom opts: ${FILE}"
generate_chapter_slides --input "${FILE}" ${OPTS[@]} || exit $?
done
DEFAULT=()
for FILE in "${ALL_MD_FILES[@]}"
do
if [[ "${FILE}" != "" ]]
then
DEFAULT+=("${FILE}")
fi
done
for FILE in "${DEFAULT[@]}"
do
echo "running default build for file: ${FILE}"
generate_chapter_slides --input "${FILE}" || exit $?
done