Skip to content

feat(toHighlight): add ignore-accents support - #862

Open
J-Sek wants to merge 5 commits into
devfrom
feat/highlight-ignore-accents
Open

feat(toHighlight): add ignore-accents support#862
J-Sek wants to merge 5 commits into
devfrom
feat/highlight-ignore-accents

Conversation

@J-Sek

@J-Sek J-Sek commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

blocks vuetify#22922

@userquin

Copy link
Copy Markdown
Member

We are using toLocaleLowerCase at diacritics, we may have some issue without using i18n lang... that method will use browser/navigator locale.

For example, having en-US at browser and using some german word.

I'm just asking...

@johnleider

Copy link
Copy Markdown
Member

@userquin The API concern is real; the German example isn't.

toLocaleLowerCase() with no argument uses the host locale (browser / Node LANG). That's a problem for a pure utility: same call, different machine, different ranges. SSR is the sharp version — Node locale vs client locale can disagree, so highlighted markup hydrates wrong.

en-US and de lowercase Straße / STRASSE / ß identically. The actual landmine is Turkic I:

'I'.toLowerCase()                   // 'i'          always
'I'.toLocaleLowerCase('tr')         // 'ı'          dotless
'İstanbul'.toLowerCase()            // 'i̇stanbul'  i + combining dot
'İstanbul'.toLocaleLowerCase('tr')  // 'istanbul'

A tr browser and an en-US browser will not highlight the same I / İ / i pairs.

This PR inherited toLocaleLowerCase from master toHighlight. createFilter already uses locale-independent toLowerCase(). The new public findMatchRanges should match that, not the host.

Don't thread useLocale() in here. findMatchRanges is #v0/utilities — no Vue, no plugin. If we ever want German/Turkish-correct case, add an explicit locale?: string later. Silent navigator language is the worst option.

I'll switch both toLocaleLowerCase() calls to toLowerCase(). The İ source map still matters; Unicode default still expands İ to two units.

@userquin

Copy link
Copy Markdown
Member

Maybe we can use 'İstanbul'.normalize('NFD').toLowerCase() (this shouldn't break)

@J-Sek

J-Sek commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author
'ΣΟΦΟΣ'.toLowerCase() // 'σοφος'
'σοφος'.toUpperCase() // 'ΣΟΦΟΣ'

And apparently it is correct, lol

@userquin

Copy link
Copy Markdown
Member
'ΣΟΦΟΣ'.toLowerCase() // 'σοφος'
'σοφος'.toUpperCase() // 'ΣΟΦΟΣ'

And apparently it is correct, lol

it looks like toLowerCase/toUpperCase is doing its work, there is no need to use normalize('NFD')

J-Sek and others added 5 commits August 19, 2026 09:15
foldWithMap now runs whenever ignoreCase or target-folding can change
length, so İ / İstanbul no longer highlights the following letter. Half
of a multi-char fold (s vs ß) expands to the whole source character
instead of a zero-width range.
toLocaleLowerCase() followed the host locale, so a tr browser and an
en-US browser (or Node vs client) would not highlight the same I/İ/i
pairs. Align with createFilter.
Also call the NFD letter map a curated set, and note that createFilter
does not fold accents yet.
@johnleider
johnleider force-pushed the feat/highlight-ignore-accents branch from 29f180b to e599b09 Compare August 19, 2026 14:20
@johnleider
johnleider changed the base branch from master to dev August 19, 2026 14:20
@johnleider johnleider added this to the v1.1.0 milestone Aug 20, 2026
@johnleider

Copy link
Copy Markdown
Member

Looking for final comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants