-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·65 lines (53 loc) · 1.31 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·65 lines (53 loc) · 1.31 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
#!/usr/bin/env bash
#
# Author: Jake Zimmerman <jake@zimmerman.io>
#
# A simple script to build an HTML file using Pandoc
#
set -euo pipefail
usage() {
echo "usage: $0 <source.md> <dest.html>"
}
# ----- args and setup -----
src="${1:-}"
dest="${2:-}"
if [ "$src" = "" ] || [ "$dest" = "" ]; then
2>&1 usage
exit 1
fi
case "$src" in
-h|--help)
usage
exit
;;
esac
if command -v grealpath &> /dev/null; then
realpath="grealpath"
elif command -v realpath &> /dev/null; then
realpath="realpath"
else
2>&1 echo "$0: This script requires GNU realpath. Install it with:"
2>&1 echo " brew install coreutils"
exit 1
fi
# ----- main -----
for file in "docs/css/theme.css" "docs/css/skylighting-solarized-theme.css"; do
if ! [ -f "$file" ]; then
2>&1 echo "$0: warning: CSS theme file is missing: $file (will 404 when serving)"
fi
done
dest_dir="$(dirname "$dest")"
mkdir -p "$dest_dir"
css_rel_path="$("$realpath" "docs/css/" --relative-to "$dest_dir")"
pandoc \
--katex="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/" \
--from markdown+tex_math_single_backslash \
--lua-filter pandoc-sidenote.lua \
--to html5+smart \
--template=template \
--css="$css_rel_path/theme.css" \
--css="$css_rel_path/skylighting-solarized-theme.css" \
--toc \
--wrap=none \
--output "$dest" \
"$src"