importing
This commit is contained in:
parent
85a5046093
commit
ee43cedfba
10 changed files with 662 additions and 66 deletions
15
bin/debian_pandoc.sh
Normal file
15
bin/debian_pandoc.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
export DEBCONF_NOWARNINGS="yes"
|
||||
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
|
||||
apt-get -qq update
|
||||
apt-get -qq -y install curl pandoc
|
||||
|
||||
_VER=$(curl -s "https://api.github.com/repos/jgm/pandoc/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
|
||||
|
||||
curl -sLo "pandoc-${_VER}-1-amd64.deb" "https://github.com/jgm/pandoc/releases/download/${_VER}/pandoc-${_VER}-1-amd64.deb"
|
||||
|
||||
apt-get -qq -y install "./pandoc-${_VER}-1-amd64.deb"
|
||||
apt-get -qq -y autoremove
|
||||
43
bin/generate_html.sh
Normal file
43
bin/generate_html.sh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/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 -r 's/(\[.*?\])\((.*?)\.md\)/\1(\2.html)/' "$file"
|
||||
# sed does not support non-greedy (.*?) like perl, we have to hack it
|
||||
sed -i -r \
|
||||
-e ':loop' \
|
||||
-e 's/(\[.*\])\((.*)\.md\)/\1(\2.html)/g' \
|
||||
-e 't loop' $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
|
||||
Loading…
Add table
Add a link
Reference in a new issue