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

feat: add option to ignore diacritics #773

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

piitaya
Copy link

@piitaya piitaya commented Jun 24, 2024

Add `ignoreDiacritics` to ignore diacritics in search
src/core/index.js Outdated Show resolved Hide resolved
@TackJordy
Copy link

Would be nice to have this feature, is someone still looking into it?

@@ -109,3 +109,46 @@ describe('ignoreLocation when useExtendedSearch is true', () => {
expect(result).toHaveLength(1)
})
})

describe('Searching using extended search ignoring diactrictics', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in other places in tests "diacritics" is spelled "diactrictics".

@jwbth
Copy link

jwbth commented Nov 20, 2024

Hi @piitaya! Glad to see this is proposed by somebody. Sad that this doesn't get attention.

I looked into your code, and this seems to be the only string transformation for the support of diacritics:
str.normalize('NFD').replace(/[\u0300-\u036F]/g, '')

Compare that with the code used by Wikimedia projects for the support of dicritics and other combining characters: https://github.com/wikimedia/oojs-ui/blob/9a2b2b42aac087db15c8a91fd6bbcef78dbd9898/src/mixins/LabelElement.js#L97-L98. This code basically powers Wikipedia when it comes to supporting combining characters in search.

The character regexp there includes many more ranges, and it is equivalent to \p{Mark} (which refers to a Unicode claracter class, but \p doesn't have a good enough browser support yet). Could you have a look?

Unfortunately, this meme well-reflects the current situation in many libs working with text:
text-libs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to ignore diacritics
5 participants