2022-05-30 23:09:40 +00:00
#!/bin/sh
# takes an arg for the output dir.
2022-06-02 05:11:40 +00:00
# Runs xhtmlize-single-file.sh on every single html file in the output dir.
2022-06-13 15:27:09 +00:00
# exits if xhtmlize-single-file fails.
2022-06-02 05:11:40 +00:00
2023-11-29 21:37:48 +00:00
#shellcheck disable=SC3040 # This only sets pipefail if it's available and otherwise does nothing
set -o pipefail 2>/dev/null || true
2022-06-02 05:11:40 +00:00
set -e -u
output_dir = " $1 "
script_dir = " $( dirname " $0 " ) "
2023-11-26 22:28:41 +00: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 22:57:42 +00: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 22:28:41 +00:00
mv " $output_dir /resume/index.html " " $temp_resume "
2024-01-30 23:50:37 +00:00
# {{ $css.Content | safeCSS }}/*]]>*/-->
2023-11-15 17:21:26 +00:00
{
2024-01-30 23:50:37 +00:00
sed -e '7q;d' " $output_dir /index.html " \
| sed -e 's|<style>|<style><\!--/\*--><\!\[CDATA\[/\*><\!--\*/|' -e 's|</style>|/\*\]\]>\*/--></style>|'
} >" $output_dir /tmp.xhtml "
2022-06-02 05:11:40 +00:00
cleanup( ) {
2024-01-30 23:50:37 +00:00
rm " $output_dir /tmp.xhtml "
mv " $temp_resume " " $output_dir /resume/index.html "
2022-06-02 05:11:40 +00:00
}
trap cleanup EXIT
export XMLLINT_INDENT = ' '
2022-08-02 03:54:25 +00:00
export OUTPUT_DIR = " $output_dir "
2023-11-29 21:37:48 +00:00
find " $output_dir " -type f -name '*.html' | xargs -n1 sh " $script_dir /xhtmlize-single-file.sh "
find " $output_dir " -type f -name '*.xml' | xargs -I_ xmllint --noblanks --encode UTF-8 --noent _ --output _