Skip to content

Conversation

Dentosal
Copy link

Sorry to introduce two changes in the same PR. I also fixed some deprecation warnings with React by moving to React.createElement style. If this is a real problem, feel free to either modify it yourself or ask me to do it in comments.

This PR adds two props: ignoreDiacritics and diacriticsBlacklist. The code uses unicode normalization to separate and combine diacritical marks from characters.

ignoreDiacritics

ignoreDiacritics allows ignoring diacritical marks when matching. For instance cafe will match café and á will match a. Currently both search and subject are simplified, so it is not possible to make á not match a, except when using diacriticsBlacklist.

diacriticsBlacklist

diacriticsBlacklist contains a list of characters excluded from diacritics removal. For example:

<Highlight
  search='Café Ääkkönen'
  ignoreDiacritics=true
  diacriticsBlacklist='ÄäÖö'
>

Will match Cafe Ääkkönen and café ääkkönen but not cafe aakkonen.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b1e281f on Dentosal:master into ** on helior:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling ba937ab on Dentosal:master into ** on helior:master**.

@helior
Copy link
Owner

helior commented Jul 1, 2017

This is a rad feature @Dentosal, thanks for your contribution! I'll give this a review sometime during the long-weekend.

@Dentosal
Copy link
Author

@helior Any problems with this? Feel free to ask if there are any issues.

@helior
Copy link
Owner

helior commented Oct 5, 2017

@Dentosal no issue with these changes, other than the current merge conflicts; also, I haven't tested this locally. If you want to make the updates I'll merge when they're ready, otherwise I'll have to put some time aside to button this up and get it merged. A lot of people will appreciate this contribution, thanks again!

var PropTypes = require('prop-types');

function removeDiacritics(str, blacklist) {
if (!String.prototype.normalize) {
Copy link
Contributor

@ericgio ericgio Jan 14, 2018

Choose a reason for hiding this comment

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

The use of normalize pretty much excludes IE. This solution is more widely cross-browser compatible.

@pasieronen
Copy link
Contributor

@helior I've rebased @Dentosal's changes on top of the current master (with some commit squashing/splitting), and tested the result with our app. I left normalize as is - if you need IE11 support, you can use a polyfill for that.

@pasieronen
Copy link
Contributor

@helior Is there something you'd like to see changed before merging this?

@helior helior merged commit f3b24bc into helior:master Jul 6, 2018
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.

5 participants