aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-spelling.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/assert-spelling.sh')
-rwxr-xr-xscripts/assert-spelling.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh
new file mode 100755
index 0000000..caaecfa
--- /dev/null
+++ b/scripts/assert-spelling.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+cd ../
+
+export LANG=C.UTF-8
+
+for DICT in scripts/spelling/*.txt; do
+ diff <(sort "$DICT") "$DICT" || {
+ echo "The $DICT dictionary is unsorted. To fix it, run:" >&2
+ echo " LANG=C.UTF-8 sort docs/$DICT | sponge docs/$DICT" >&2
+ exit 1
+ }
+done
+
+OUT="$(mktemp)"
+shopt -s globstar
+jekyll build
+for f in _site/**/*.html; do
+ if ! grep -E '^_site/pastebin' <(echo "$f") > /dev/null; then
+ if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then
+ l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)"
+ hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT"
+ fi
+ fi
+done
+
+if [[ -s "$OUT" ]]; then
+ printf "\nvvv Mispelled words detected by hunspell.\n\n"
+ sort < "$OUT" | uniq
+ printf "\n^^^\n" >&2
+ exit 1
+else
+ echo "No spelling errors detected"
+ exit 0
+fi