add meditation and pre-commit scripts
This commit is contained in:
+19
-41
@@ -26,7 +26,7 @@ fi
|
||||
|
||||
echo "Checking markdown files..."
|
||||
|
||||
# Check markdown formatting with markdownlint-cli
|
||||
# --- Stage 1: Markdown linting ---
|
||||
if command -v markdownlint &> /dev/null; then
|
||||
if ! markdownlint $STAGED_MD_FILES; then
|
||||
echo "❌ Markdown linting failed."
|
||||
@@ -38,50 +38,28 @@ else
|
||||
echo "⚠️ markdownlint not found, skipping markdown linting"
|
||||
fi
|
||||
|
||||
# Spell check
|
||||
if command -v aspell &> /dev/null; then
|
||||
# Check if aspell can find dictionaries
|
||||
if ! aspell dump dicts 2>/dev/null | grep -q "en"; then
|
||||
echo "⚠️ aspell found but no English dictionaries available"
|
||||
echo " Make sure ASPELL_CONF is set correctly in your direnv"
|
||||
echo " Skipping spell check"
|
||||
else
|
||||
echo "Running spell check..."
|
||||
MISSPELLED=0
|
||||
for file in $STAGED_MD_FILES; do
|
||||
# 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:"
|
||||
# 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"
|
||||
echo -e "\nMisspelled words:\n"
|
||||
while IFS= read -r word; do
|
||||
echo "$word"
|
||||
done <<< "$ERRORS"
|
||||
MISSPELLED=1
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
if [ $MISSPELLED -eq 1 ]; then
|
||||
echo "❌ Spell check failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
# --- Stage 2: Tag similarity check ---
|
||||
if command -v python3 &> /dev/null && [ -f "./scripts/check-tags.py" ]; then
|
||||
echo "Running tag similarity check..."
|
||||
if ! python3 ./scripts/check-tags.py $STAGED_MD_FILES; then
|
||||
echo "❌ Tag similarity check failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
else
|
||||
echo "⚠️ aspell not found, skipping spell check"
|
||||
echo "⚠️ Tag checker (python3 or scripts/check-tags.py) not found, skipping tag check"
|
||||
fi
|
||||
|
||||
# Link validation
|
||||
# --- Stage 3: Interactive spell check ---
|
||||
if [ -x "./scripts/spellcheck-interactive.sh" ]; then
|
||||
if ! ./scripts/spellcheck-interactive.sh $STAGED_MD_FILES; then
|
||||
echo "❌ Spell check failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Spell check script not found or not executable, skipping spell check"
|
||||
fi
|
||||
|
||||
# --- Stage 4: Link validation ---
|
||||
if [ -x "./scripts/check-links.sh" ]; then
|
||||
echo "Running link validation..."
|
||||
if ! ./scripts/check-links.sh $STAGED_MD_FILES; then
|
||||
|
||||
Reference in New Issue
Block a user