-
Notifications
You must be signed in to change notification settings - Fork 21
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
2992: Replace normalize-strings #3108
base: main
Are you sure you want to change the base?
Conversation
I think |
[Continuing the discussion here] |
So I have done some more research into the Eszett (ß) situation. This is what I have come up with.
PS.: string.normalize() does not replace ß with ss in any version of normalization (NFC, NFD, NFKC, NFKD), but this can be done by hand |
Sounds great, I like your suggestion. Lets go with that 🔍 |
@hannaseithe do you want to create an issue in the entitlementcard repository for this problem and with your findings? Thanks :) |
I think a solution making use of the default import { findChunks } from 'highlight-words-core'
const findNormalizedChunks = (props: FindChunks): Chunk[] => {
const chunks: Chunk[] = findChunks(props)
return chunks.map(chunk => {
const match = props.textToHighlight.slice(chunk.start, chunk.end)
const sanitationAdditionalChars = match.split('ß').length - 1
return { start: chunk.start, end: chunk.end - sanitationAdditionalChars }
})
} Also, the current solution crashes for me when entering |
bb034a6
to
fa6db2d
Compare
@@ -79,7 +79,6 @@ | |||
"react-native-calendars": "^1.1306.0", | |||
"react-native-gesture-handler": "^2.19.0", | |||
"react-native-get-random-values": "^1.11.0", | |||
"react-native-highlight-words": "^1.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unmaintained and does not support custom findChunks
method, so I wrote a custom Highlighter component
535f3a4
to
cb51398
Compare
cb51398
to
49a5832
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work ✨
Unfortunately there is one issue left.. if you searched in Arabic (after you switch the language) it will return the whole list due to replacing non-Ascii letters and Arabic uses non ascii as far as I know.
You can test it by typing اللغة
Very good catch, thanks for testing thoroughly. Should be fixed now, could you please check again? |
"strasse" now doesn't show same results as "straße" maybe writing a condition to check the language whether it's Deutsch? |
Yes. I think that check is not necessary, this normalization should always be done imo, no matter the user language. |
Keep normalization but change the regex for Deutsch to |
Why? What benefit does that serve? In what usecase would we not want to use the same regex? |
9661cc4
to
0d17160
Compare
0d17160
to
689219f
Compare
Thank you, another great catch... I guess I was a little fast in fixing/testing last time. Please recheck, should now hopefully work as expected. |
Short Description
The dependency on the library 'normalize-string' has been replaced by the ES6 String.normalize() method. This has been implemented following the approach of digitalfabrik/entitlementcard/#1782
Proposed Changes
Side Effects
Testing
Resolved Issues
Fixes: #2992