-
Notifications
You must be signed in to change notification settings - Fork 169
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
Handling more complicated searchWord / matches scenarios (regex) #43
Comments
I think ideally, I could use https://www.npmjs.com/package/xregexp-lookbehind in my app which uses |
Hi. You're welcome to submit a PR that adds a support for I'd want to avoid adding a new external dependency directly to this lib though! 😄 |
Hi @bvaughn I needed to also customize the core repo because in I had some big trouble developing this because both projects have different (old) babel configs and then working with And then I am also on Windows here, that's why I added I could not run the tests, something was broken with the |
I managed to run the tests and added new tests to the core and this repo. |
Left you some feedback! |
I'm closing now that the custom Thanks again! :) |
Thank you. |
I have a few requirements that are hard to meet knowing:
\b
(word boundary) only works with ASCII chars, so is not really suitable for most real languages. Possible solution would be to use XRegExp (a wrapper around the native jsRegExp
), but this is not part of react-highlight-words. And I do not know if you wanna do the buy-in of addingXRegExp
searchWord=['Ma']
inSmith-Mayer
theMa
should be highlighted. If it starts with-
, but the-
should not be part of match (not be highlighted).look-behind
andlook-around
regexes at all. Various other workarounds available on Stackoverflow, but they all require some JS fiddling....So why am I writing this:
Also, I am not sure on how to proceed here :)
Looking into the source, my proposal would be to allow the
findChunks
function to be overridden as aprop
(like there issanitize
already). Especially, all the above problem could be moved into the using app's domain if these lines could be overridden using aprop
or similar:https://github.com/bvaughn/highlight-words-core/blob/7cbba8346e08a68cbba77e7ef2c7df65f7dd1422/src/utils.js#L83-L89
I might try to send a PL, but not sure what direction to take considering the alternatives.
The text was updated successfully, but these errors were encountered: