Skip to content

Commit 7a520ce

Browse files
committed
Expand preprocessing in check-doc-aspell
1 parent 2698b95 commit 7a520ce

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

scripts/check-doc-aspell

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,32 @@ get_ignore_words_for_file() {
6767
# Use this to filter out lines we don't wanna consider in spell-check - slugs, imports, and img src JSX elements
6868
preprocess_file() {
6969
local file=$1
70-
sed -E 's/\{#[^}]*\}//g' "$file" | grep -Ev '^(slug:|import [[:alnum:]_, {}*]+ from .+;?|<img src=\{[^}]+\})'
70+
71+
# Remove YAML frontmatter (everything between the first --- and second --- lines)
72+
# Then apply other existing filters
73+
awk '
74+
BEGIN {
75+
in_frontmatter = 0
76+
frontmatter_ended = 0
77+
}
78+
# If first line is ---, we are starting frontmatter
79+
/^---$/ && NR == 1 {
80+
in_frontmatter = 1
81+
next
82+
}
83+
# If we encounter --- while in frontmatter, end it
84+
/^---$/ && in_frontmatter {
85+
in_frontmatter = 0
86+
frontmatter_ended = 1
87+
next
88+
}
89+
# Print lines only if not in frontmatter
90+
!in_frontmatter { print }
91+
' "$file" \
92+
| sed -E 's/\{#[^}]*\}//g' \
93+
| sed -E 's/<[A-Za-z0-9_]+svg[^>]*\/?>//g' \
94+
| sed -E 's/<Image[^>]*\/?>//g' \
95+
| grep -Ev '(^[[:space:]]*(slug:|<img src=\{[^}]+\})|^import .* from .*)'
7196
}
7297
# List of files to ignore
7398
IGNORE_LIST=(

0 commit comments

Comments
 (0)