blob: 127847975dca96b4f151957c1e5e74212afe3fae (
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
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/bash
MARKDOWN_DIR="Markdown"
MARKDOWN_DIR_LENGTH=$(expr 1 + ${#MARKDOWN_DIR})
HTML_DIR="Page"
# clean_html_files: IO ()
clean_html_files () {
rm -rf "$HTML_DIR"
}
# write_html_file: FilePath -> FilePath -> IO ()
write_html_file () {
mkdir -p $(dirname "$2")
cat Fragments/begin.html > "$2"
pandoc -t html "$1" >> "$2"
cat Fragments/end.html >> "$2"
}
echo ""
echo "> Generating HTML files…"
clean_html_files
SELECTOR="${MARKDOWN_DIR}/*.md ${MARKDOWN_DIR}/**/*.md"
for FILENAME in $SELECTOR; do
WITHOUT_DIR=${FILENAME:$MARKDOWN_DIR_LENGTH}
WITHOUT_EXT=${WITHOUT_DIR%.*}
HTML_FILENAME="$HTML_DIR/$WITHOUT_EXT.html"
write_html_file "$FILENAME" "$HTML_FILENAME"
done
write_html_file "$MARKDOWN_DIR/Index.md" index.html
rm -f makeup && ln -s . makeup
echo "> Done !"
|