38 lines
998 B
Bash
38 lines
998 B
Bash
#!/usr/bin/env bash
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# gitlab-ci looks here
|
|
[[ ! -d ./public ]] && mkdir ./public
|
|
|
|
# copy our CSS - <link rel="stylesheet" href="${_CSS}" />
|
|
_CSS="mdhtml.css"
|
|
cp "./style/${_CSS}" ./public/
|
|
|
|
# icon
|
|
_FAV="favicon.ico"
|
|
cp "./style/${_FAV}" ./public/
|
|
|
|
# ./src/foo.md -> ./public/foo.html
|
|
for file in ./src/*.md; do
|
|
_FILE="${file##*/}"
|
|
_HTML="./public/${_FILE%.*}.html"
|
|
echo "Processing $file to $_HTML"
|
|
|
|
# metadata for pandoc
|
|
_TITLE=$(grep -m1 "^# " "$file" | sed -r 's/# //')
|
|
|
|
# [foo](foo.md) -> [foo](foo.html)
|
|
sed -i -E 's/(\[[^)]*\])\((([^.]*\.)*)md\)/\1(\2html)/g' $file
|
|
|
|
pandoc -s \
|
|
-f gfm+gfm_auto_identifiers-ascii_identifiers \
|
|
-t html \
|
|
--template="./style/pandoc_html.tpl" \
|
|
--include-in-header="./style/header_include.html" \
|
|
--include-before-body="./style/body_before.html" \
|
|
--include-after-body="./style/body_after.html" \
|
|
--metadata pagetitle="$_TITLE" \
|
|
--css="${_CSS}" \
|
|
-o "${_HTML}" "$file"
|
|
done
|