blob: 653a5f95a1ddab3905551be26a9e07617f06f72f (
plain) (
tree)
|
|
#!/usr/bin/env bash
set -Eeuo pipefail
HTML_DIR="${1:-}"
[[ -z "${HTML_DIR}" ]] && {
echo 'Undefined input HTML_DIR.' >&2
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:" >&2
echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2
exit 1
}
done
finish() {
rm -f spelling.txt
rm -f dicts.txt
}
trap finish EXIT
cat spelling/*.txt > dicts.txt
find "${HTML_DIR}" -type f -name '*.html' | grep -v pastebin | hunspell -l -p dicts.txt -d fr_FR -d en_US -i utf-8 >> spelling.txt
if [[ -s spelling.txt ]]; then
printf "\nvvv Mispelled words detected by hunspell.\n\n" >&2
sort < spelling.txt | uniq >&2
printf "\n^^^\n" >&2
exit 1
else
echo "No words mispelled" >&2
fi
|