blob: 6d5f3c708fbb6028b63c67fc332bc7795855244b (
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
|
#!/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
echo "> Done !"
|