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

Hack explanation #1

Open
dmarman opened this issue Dec 26, 2017 · 0 comments
Open

Hack explanation #1

dmarman opened this issue Dec 26, 2017 · 0 comments

Comments

@dmarman
Copy link

dmarman commented Dec 26, 2017

if (match.length === 2) {

First of all thanks for this repository 👍

I am trying to use your package using regex expressions instead of words. Something like:

config: {
                longWord: {
                    matchcase: false,
                    wordsonly: false,
                    class: 'long-word',
                    words: ['[a-zA-z]{14,}']
                }
}

It is actually working properly.
But I notice that some expressions doesn't work. If I use something like words: ['([a-z]+ ){1,}'] won't work. I realize it is because of the "(" and ")". The code will fire window.console.error('Cannot process: ' + match);
If I use words: ['([a-z]+ ){1,}'] then matches.length = 3 which will never be processed since the code only accepts lengths of 2 and 4.
I tried changing your code to if (match.length === 2 || match.length === 3) this will style the content but will set the caret at the begginng :(

Could you explain please a little bit more about this hack and why sometimes it outputs 3 matches? Do you think I should change some parts of your code in order to use regex explessions instead of words?

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

No branches or pull requests

1 participant