-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathfix_curly_quotes.sh
More file actions
executable file
·57 lines (50 loc) · 1.6 KB
/
fix_curly_quotes.sh
File metadata and controls
executable file
·57 lines (50 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Fix curly/smart quotes by replacing them with straight quotes
#
# Replaces:
# " (U+201C) → " - Left double quotation mark
# " (U+201D) → " - Right double quotation mark
# ' (U+2018) → ' - Left single quotation mark
# ' (U+2019) → ' - Right single quotation mark
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Default to src/ if no arguments provided
if [ $# -eq 0 ]; then
SEARCH_PATHS="src/"
else
SEARCH_PATHS="$@"
fi
# Find all relevant files
FILES=$(find $SEARCH_PATHS \
-type f \
\( -name "*.md" -o -name "*.mdx" -o -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" \) \
-not -path "*/reference/*" \
-not -path "*/build/*" \
-not -path "*/node_modules/*" \
-not -path "*/.git/*" \
-not -path "*/.venv/*" \
-not -path "*/__pycache__/*" \
2>/dev/null || true)
FIXED_COUNT=0
for file in $FILES; do
if grep -q -E '[""'']' "$file" 2>/dev/null; then
echo -e "${YELLOW}Fixing: $file${NC}"
# Use sed to replace curly quotes with straight quotes
# macOS and Linux compatible
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -e 's/[""]/"/g' -e "s/['']/'/g" "$file"
else
sed -i -e 's/[""]/"/g' -e "s/['']/'/g" "$file"
fi
FIXED_COUNT=$((FIXED_COUNT + 1))
fi
done
if [ $FIXED_COUNT -gt 0 ]; then
echo ""
echo -e "${GREEN}Fixed curly quotes in $FIXED_COUNT file(s).${NC}"
else
echo -e "${GREEN}No curly quotes found. Nothing to fix.${NC}"
fi