Use lodash to remove accents and ther diacritics

https://lodash.com/docs/4.17.15#deburr
This commit is contained in:
Ronan Amicel
2022-08-17 18:35:50 +02:00
parent 0249b3d31b
commit 4003d2d7c6
2 changed files with 6 additions and 9 deletions

View File

@@ -7,9 +7,10 @@
* "lush" would only match the "L" in "Lavender".
*/
import {localeCompare, nativeCompare, removeDiacritics, sortedIndex} from 'app/common/gutil';
import {localeCompare, nativeCompare, sortedIndex} from 'app/common/gutil';
import {DomContents} from 'grainjs';
import escapeRegExp = require("lodash/escapeRegExp");
import deburr = require("lodash/deburr");
export interface ACItem {
// This should be a trimmed lowercase version of the item's text. It may be an accessor.
@@ -17,10 +18,11 @@ export interface ACItem {
cleanText: string;
}
// Returns a normalized, trimmed, lowercase version of a string, so that autocomplete is case-
// and accent-insensitive.
// Returns a trimmed, lowercase version of a string,
// from which accents and other diacritics have been removed,
// so that autocomplete is case- and accent-insensitive.
export function cleanText(text: string): string {
return removeDiacritics(text).trim().toLowerCase();
return deburr(text).trim().toLowerCase();
}
// Regexp used to split text into words; includes nearly all punctuation. This means that