#!/bin/bash date=$(date -u "+%Y-%m-%d %H:%M:%S") repo="$(git config --get remote.origin.url)/tree/main/pocs" mkdir -p docs/ &>/dev/null if test -d pandoc/assets; then cp -r pandoc/assets docs/ else printf "%s\n" "[err] pandoc/assets/ dir not found" exit 1 fi if command -v pandoc &>/dev/null; then count=$(cat pocs/README.md | wc -l) size=$(du -sh pocs/ | awk '{print $1}') if (tac pocs/README.md | pandoc \ -s \ --toc \ --metadata "title=cve proof of concepts" \ --metadata "date=${date} utc" \ --metadata "repo=${repo}" \ --metadata "rss_url=https://cve.heqnx.com/feed.xml" \ --metadata "count=${count}" \ --metadata "size=${size}" \ --template pandoc/template.html \ --lua-filter=pandoc/add-target-blank.lua \ -o docs/index.html); then \ printf "%s\n" "[inf] successfully generated html" > docs/.nojekyll else printf "%s\n" "[err] error generating html" fi if command -v tidy &>/dev/null; then if tidy --indent yes --wrap 0 -m --quiet yes --indent-spaces 2 --tidy-mark no docs/index.html; then printf "%s\n" "[inf] prettified html" else printf "%s\n" "[err] failed to prettify html" fi else printf "%s\n" "[warn] tidy not found, skipping html prettify" fi else printf "%s\n" "[err] pandoc not found" exit 1 fi