blob: 04f79ffb4c0ed75bb99deee79b27c005f3457bd0 (
plain)
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
|
#!/bin/bash
[[ -v VERBOSE ]] && set -x
markdown_path="$1"
markdown_file="$(basename "$markdown_path")"
markdown_stem="$(printf %s "$markdown_file" | sed s/.md//)"
build_dir="$(dirname "$markdown_path")"/.build
[ -e "$build_dir" ] || mkdir "$build_dir"
dep_file="$build_dir"/"$markdown_stem".d
mapfile -t includes < <(grep -A2 -F '```{.include}' "$markdown_path" | awk '/include/{getline; print}')
mapfile -t images < <(grep -oP '!\[.*\]\([^\)]*' "$markdown_path" | sed 's/\!\[\](//g')
deps=("${includes[@]}" "${images[@]}")
case "$markdown_file" in
moodle-quiz.md)
target_file="moodle-quiz.xml"
;;
*)
target_file="$(printf %s "$markdown_file" | sed s/.md/.pdf/)"
;;
esac
printf "${target_file}: ${markdown_file} %s\n" "${deps[*]}" > "$dep_file"
|