diff options
author | EuAndreh <eu@euandre.org> | 2021-01-27 15:55:27 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-01-27 15:58:51 -0300 |
commit | 451eed829916627e9248f1003752b43617a20ff4 (patch) | |
tree | 1799faf7932caab2f2b6fb0bccebf06601715dda /scripts/assert-spelling.sh | |
parent | Update link to "remembering" (diff) | |
download | euandre.org-451eed829916627e9248f1003752b43617a20ff4.tar.gz euandre.org-451eed829916627e9248f1003752b43617a20ff4.tar.xz |
mv build-aux/ -> aux/ and scripts/
Diffstat (limited to 'scripts/assert-spelling.sh')
-rwxr-xr-x | scripts/assert-spelling.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh new file mode 100755 index 0000000..f0053b4 --- /dev/null +++ b/scripts/assert-spelling.sh @@ -0,0 +1,35 @@ +#!/bin/sh +set -eu + +export LANG=C.UTF-8 +export JEKYLL_ENV=production + +for DICT in scripts/spelling/*.txt; do + sort "$DICT" | diff - "$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 + +OUT="$(mktemp)" +jekyll build --future --trace +# shellcheck disable=2044 +for f in $(find _site -type f -name '*.html'); do + if ! echo "$f" | grep -qE '(/vendor/|TODOs.html)'; then + l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)" + CURR_DICT="$(mktemp)" + cat scripts/spelling/international.txt "scripts/spelling/$l.txt" > "$CURR_DICT" + hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$OUT" + fi +done + +if [ -s "$OUT" ]; then + printf "\nvvv Mispelled words detected by hunspell.\n\n" + cut -d\ -f2- < "$OUT" | sort | uniq + printf "\n^^^\n" >&2 + exit 1 +else + echo "No spelling errors detected" + exit 0 +fi |