2022-08-13 14:05:16 -07:00
#!/bin/sh
2023-11-25 13:32:55 -08:00
# Runs the Nu HTML checker (assumed to be available on your $PATH as `vnu`) on all pages.
#shellcheck disable=SC3040 # This only sets pipefail if it's available and otherwise does nothing
set -o pipefail 2>/dev/null || true
2022-08-13 14:05:16 -07:00
set -e -u
2023-11-23 18:45:03 -08:00
dirname = " $( dirname " $0 " ) "
2022-08-13 14:05:16 -07:00
output_dir = " $1 "
2023-11-25 13:32:55 -08:00
# List all HTML, XHTML, and SVG files we wish to check.
# We test both XHTML and HTML files, despite the fact that they are identical, because we want to validate under both an HTML and XML parser. VNU has some HTML-only checks.
2023-11-15 02:31:06 -08:00
find_files_to_analyze( ) {
2023-11-25 13:32:55 -08:00
find " $output_dir " -type f -name '*.html' -o -name '*.xhtml' -o -name '*.svg' \
2022-08-13 14:05:16 -07:00
| grep -Ev '(bimi\.svg|search/index\.x?html)$'
}
2023-11-25 13:32:55 -08:00
# Force a non-zero exit code for vnu. We'll decide the exit status after filtering out false-posives.
vnu_nofail( ) {
xargs vnu --stdout --format json --also-check-svg || true
}
2023-11-23 18:45:03 -08:00
# files_to_analyze="$(find_files_to_analyze)"
2023-11-15 02:31:06 -08:00
2022-08-13 14:05:16 -07:00
# we skip the BIMI icon (VNU can't handle SVG 1.2) and the search page (it has raw templates).
2023-11-23 18:45:03 -08:00
find_files_to_analyze \
2023-11-25 13:32:55 -08:00
| vnu_nofail \
2023-11-23 18:45:03 -08:00
| sh " $dirname /filter-vnu.sh "