Skip to content

Instantly share code, notes, and snippets.

@elementbound
Created February 21, 2021 11:11
Show Gist options
  • Save elementbound/0d92367e8a1f493c2e1adfff7a814a56 to your computer and use it in GitHub Desktop.
Save elementbound/0d92367e8a1f493c2e1adfff7a814a56 to your computer and use it in GitHub Desktop.
Render a given release from changelog to PNG
#!/bin/sh
# Dependencies:
# pandoc: https://pandoc.org/installing.html#linux
# wkhtmltox: https://wkhtmltopdf.org/downloads.html
changelog=$1
release=$2
if [ -z "$changelog" ] || [ -z "$release" ]; then
echo "Usage: $0 [changelog] [release]";
exit 1;
fi;
AWK_PROGRAM=$(cat <<- EOAWK
BEGIN {
active="false";
}
/##/ {
if (\$1 == "##") {
if (\$2 == "$release") {
active = "true";
} else {
active = "false";
}
}
}
{
if (active == "true")
print;
}
EOAWK
)
# Template directory is fixed to "pandoc-template/", feel free to change
awk "$AWK_PROGRAM" $changelog | pandoc -f markdown -t html \
--template=pandoc-template/template.html \
--css=pandoc-template/template.css \
--self-contained \
-o CHANGELOG.html
wkhtmltoimage --width 720 CHANGELOG.html CHANGELOG.png
rm CHANGELOG.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment