2022-05-30 16:09:40 -07:00
#!/bin/sh
# takes an arg for the output dir.
2022-06-01 22:11:40 -07:00
# Runs xhtmlize-single-file.sh on every single html file in the output dir.
2022-06-13 08:27:09 -07:00
# exits if xhtmlize-single-file fails.
2022-06-01 22:11:40 -07:00
2023-11-25 13:40:52 -08:00
# no pipefail here since there are no pipes.
2022-06-01 22:11:40 -07:00
set -e -u
output_dir = " $1 "
script_dir = " $( dirname " $0 " ) "
2023-11-26 14:28:41 -08:00
temp_resume = " $( mktemp) "
# I have an alias for a redirect. I also define the redirect in Nginx, but this is there for the envs.net/~seirdy mirror. Hugo aliases don't have trailing slashes; this will trip up xmllint.
2023-11-26 14:57:42 -08:00
sed -i -e 's|<html lang="en-us"|<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"|' -E -e 's#<((link|meta) .*)">#<\1" />#' " $output_dir /resume/index.html "
2023-11-26 14:28:41 -08:00
mv " $output_dir /resume/index.html " " $temp_resume "
2022-06-01 22:11:40 -07:00
2023-11-15 09:21:26 -08:00
{
printf '\t' && sed -e '7q;d' " $output_dir /index.html "
} >" $output_dir /tmp.css "
2022-06-01 22:11:40 -07:00
cleanup( ) {
2022-08-01 20:54:25 -07:00
rm -f " $output_dir /tmp.css "
2023-11-26 14:28:41 -08:00
mv " $temp_resume " " $output_dir /resume/index.html "
2022-06-01 22:11:40 -07:00
}
trap cleanup EXIT
export XMLLINT_INDENT = ' '
2022-08-01 20:54:25 -07:00
export OUTPUT_DIR = " $output_dir "
2023-11-15 02:26:52 -08:00
find " $output_dir " -type f -name '*.html' -exec sh " $script_dir /xhtmlize-single-file.sh " { } \;
2023-11-25 19:05:53 -08:00
find " $output_dir " -type f -name '*.xml' -exec xmllint --noblanks --encode UTF-8 --noent { } --output { } \;