From 43c7f6385bac45ed67e381d968e7873e0fb8cff0 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 6 Feb 2020 03:35:26 -0300 Subject: WIP setup hunspell --- spelling/check-spelling.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 spelling/check-spelling.sh (limited to 'spelling/check-spelling.sh') diff --git a/spelling/check-spelling.sh b/spelling/check-spelling.sh new file mode 100755 index 0000000..653a5f9 --- /dev/null +++ b/spelling/check-spelling.sh @@ -0,0 +1,38 @@ +#!/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 -- cgit v1.2.3