Added better spell check precommit check, personal dictionary, finished til post
This commit is contained in:
+14
-5
@@ -16,7 +16,6 @@ echo "Checking markdown files..."
|
||||
|
||||
# Check markdown formatting with markdownlint-cli
|
||||
if command -v markdownlint &> /dev/null; then
|
||||
echo "Running markdownlint..."
|
||||
markdownlint $STAGED_MD_FILES || {
|
||||
echo "❌ Markdown linting failed. Fix issues or use 'git commit --no-verify' to skip."
|
||||
exit 1
|
||||
@@ -36,16 +35,26 @@ if command -v aspell &> /dev/null; then
|
||||
echo "Running spell check..."
|
||||
MISSPELLED=0
|
||||
for file in $STAGED_MD_FILES; do
|
||||
# Extract text, strip markdown syntax, check spelling
|
||||
ERRORS=$(cat "$file" | aspell list --mode=markdown --personal=./.aspell.personal 2>/dev/null | sort -u)
|
||||
# Get list of misspelled words
|
||||
ERRORS=$(cat "$file" | aspell list --mode=markdown --lang=en --personal=./.aspell.en.pws 2>/dev/null | sort -u)
|
||||
if [ ! -z "$ERRORS" ]; then
|
||||
echo "⚠️ Possible misspellings in $file:"
|
||||
echo "$ERRORS" | sed 's/^/ /'
|
||||
# For each misspelled word, show context
|
||||
while IFS= read -r word; do
|
||||
if [ ! -z "$word" ]; then
|
||||
SUGGESTION=$(echo "$word" | aspell pipe --mode=markdown --lang=en --personal=./.aspell.en.pws 2>/dev/null | grep -E "^&" | cut -d: -f2 | cut -d, -f1 | sed 's/^ //')
|
||||
echo " '$word' → suggestion: $SUGGESTION"
|
||||
# Use grep to find lines containing the word (case-insensitive) with line numbers
|
||||
grep -n -i -w --color=always "$word" "$file" | head -3 | while IFS= read -r line; do
|
||||
echo " $line"
|
||||
done
|
||||
fi
|
||||
done <<< "$ERRORS"
|
||||
MISSPELLED=1
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
if [ $MISSPELLED -eq 1 ]; then
|
||||
echo ""
|
||||
echo "Review spelling errors above. Add correct terms to .aspell.personal"
|
||||
echo "Use 'git commit --no-verify' to skip if needed."
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user