Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Assistant: Write Brief should not flag words like '2nd' and '100th' as spelling errors. #39880

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

AI Assistant: Write Brief should not flag words like '2nd' and '100th' as spelling errors.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ export default function spellingMistakes( text: string ): Array< HighlightedText
// \p{M} matches any Unicode mark (combining characters)
// The regex has three main parts:
// 1. [@#+$/]{0,1} - Optionally matches a single special character at the start
// 2. [\p{L}\p{M}'-]+ - Matches one or more letters, marks, apostrophes, or hyphens
// 3. (?:\/[\p{L}\p{M}'-]+)* - Optionally matches additional parts separated by slashes
const wordRegex = new RegExp( /[@#+$/]{0,1}[\p{L}\p{M}'-]+(?:\/[\p{L}\p{M}'-]+)*/gu );
// 2. [\p{L}\p{M}\p{N}'-]+ - Matches one or more letters, marks, numbers, apostrophes, or hyphens
// 3. (?:\/[\p{L}\p{M}\p{N}'-]+)* - Optionally matches additional parts separated by slashes
const wordRegex = new RegExp( /[@#+$/]{0,1}[\p{L}\p{M}\p{N}'-]+(?:\/[\p{L}\p{M}\p{N}'-]+)*/gu );
const matches = Array.from( text.matchAll( wordRegex ) );

matches.forEach( match => {
Expand All @@ -199,6 +199,11 @@ export default function spellingMistakes( text: string ): Array< HighlightedText
return;
}

// Skip anything that is a valid number
if ( ! isNaN( Number( word ) ) ) {
return;
}

// Split words by hyphens and slashes
const subWords = word.split( /[-/]/ );

Expand Down
Loading