aboutsummaryrefslogtreecommitdiff
path: root/spelling/check-spelling.sh
diff options
context:
space:
mode:
Diffstat (limited to 'spelling/check-spelling.sh')
-rwxr-xr-xspelling/check-spelling.sh21
1 files changed, 10 insertions, 11 deletions
diff --git a/spelling/check-spelling.sh b/spelling/check-spelling.sh
index 653a5f9..3ddfd2a 100755
--- a/spelling/check-spelling.sh
+++ b/spelling/check-spelling.sh
@@ -11,22 +11,21 @@ HTML_DIR="${1:-}"
export LANG=C.UTF-8
for DICT in spelling/*.txt; do
- diff <(sort "$DICT") "$DICT" || {
+ diff <(sort "$DICT" | uniq) "$DICT" || {
echo "The $DICT dictionary is unsorted. To fix it, run:" >&2
- echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2
+ echo " LANG=C.UTF-8 sort $DICT | uniq | 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
+rm -f spelling.txt
+shopt -s globstar
+for f in "${HTML_DIR}"/**/*.html; do
+ if ! grep -E '/pastebin(/|s.html)' <(echo "$f") > /dev/null; then
+ l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)"
+ hunspell -u3 -H -d "$l" -p <(cat spelling/international.txt "spelling/$l.txt") "$f" | tee -a spelling.txt
+ fi
+done
if [[ -s spelling.txt ]]; then
printf "\nvvv Mispelled words detected by hunspell.\n\n" >&2