open-goverance/_scripts/format_handovers.sh
Brendan Golden 04b9be1fbc
fix: turns out wkhtmltopdf has been depreciated for two years
It was running on a version of QT4 that hadnt gotten a browser update since 2015.
See https://wkhtmltopdf.org/status.html for more info

Its a shame to use a chrome based renderer for this but I would rather have somethign that would work
At least we got teh nix cache out of this though
2024-05-13 15:00:36 +01:00

44 lines
No EOL
883 B
Bash
Executable file

#!/usr/bin/env bash
cd Committee
# copy in teh config for this folder
cp ../_scripts/md_toml/_Handovers.md.toml ./.md.toml
cargo-bfom
## cleanup
rm -f .md.toml
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
cd _Handovers_html
out_folder="../_Handovers_pdf"
rm -rf "$out_folder"
for d in */ ; do
# skip symlinks
[ -L "''${d%/}" ] && continue
# exclude teh template fodler
if [[ $d == *"_Templates"* ]]; then
continue
fi
# create output folder
mkdir -p "$out_folder/$d"
# iterate the files
for file in $d*.html; do
if [ -f "$file" ]; then
# we need teh filename/path
stripped=''${file/.html/""}
echo "$out_folder/$stripped.pdf"
# convert teh html to pdf
puppeteer print "$stripped.html" "$out_folder/$stripped.pdf" 2> ./tmp.txt
fi
done
done
cd ../