blob: b3bb15f30dc7956a198e26426a06768c01c12112 (
plain) (
tree)
|
|
#!/usr/bin/env bash
set -Eeuo pipefail
HTML_DIR="${1:-}"
[[ -z "${HTML_DIR}" ]] && {
echo 'Undefined input HTML_DIR.'
exit 2
}
# Required by =sort= and =hunspell=
export LANG=C.UTF-8
for DICT in spelling/*.txt; do
diff <(sort "$DICT") "$DICT" || {
echo "The $DICT dictionary is unsorted. To fix it, run:"
echo " LANG=C.UTF-8 sort $DICT | sponge $DICT"
exit 1
}
done
cat spelling/international.dic.txt spelling/en_US.dic.txt spelling/en_US.aff.txt > dicts.txt
check() {
html="$1"
echo "$1"
hunspell -l -p dicts.txt -d en_US -i utf-8 "$html" | tee -a spelling.txt
}
export -f check
find "${HTML_DIR}" -type f -name '*.html' -print0 | xargs -0 -I{} bash -c "check {}" \;
if [[ -s spelling.txt ]]; then
printf "\nvvv Mispelled words detected by hunspell.\n\n"
cat spelling.txt
printf "\n^^^\n"
exit 1
else
echo "No words mispelled"
fi
|