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

Spelling error does not trigger with the DOM has only ONE word #56

Open
shriniv78 opened this issue Sep 13, 2013 · 5 comments
Open

Spelling error does not trigger with the DOM has only ONE word #56

shriniv78 opened this issue Sep 13, 2013 · 5 comments

Comments

@shriniv78
Copy link

In the demo environment url below, if you erase everything and just type one bad spelling "eg: denounncing", the error style/event bind does not happen. Same issue in my local. I am using nhunspell, and newton for my backend.

Also, its the same issue if the first word or the last word contains has bad spelling.

http://jquery-spellchecker.badsyntax.co/ckeditor.html

@motan
Copy link

motan commented Oct 3, 2013

I've fixed it in my project.

we need to update code in HtmlParser.prototype.highlightWords method.

find

var regExp = '';
regExp += '([^' + letterChars + '])';
regExp += '(' + incorrectWords.join('|') + ')';
regExp += '(?=[^' + letterChars + '])';

and replace it with

var regExp = '';
regExp += '([^' + letterChars + ']?)';
regExp += '(' + incorrectWords.join('|') + ')';
regExp += '(?=[^' + letterChars + ']?)';

(in 2 and 4 rows "?"-sign added before closing bracket)

@bryandevvv
Copy link

The regex fix listed by motan does not work for me, because it highlights misspelled words in other words. For instance if "wor" were highlighted as misspelled, any "wor" in "word" would also be highlighted.
Any regex masters out there? The library as is does not highlight the first word, or words directly after a newline or html tag for me.

@tangruixing
Copy link

i replace it with

var regExp = '';
regExp += '(^|[^' + letterChars + '])';
regExp += '(' + incorrectWords.join('|') + ')';
regExp += '(?=[^' + letterChars + ']|$)';

@ss81
Copy link

ss81 commented Dec 1, 2014

The patch provided by tangruixing works well for me.

@bogdan-dinu-me
Copy link

the last patch doesn't match last words in paragraphs that don't have a punctuation sign.

I propose this variant which matches both first and last words:

var regExp = '';
regExp += '(^|[^' + letterChars + ']?)';
regExp += '(' + incorrectWords.join('|') + ')';
regExp += '(?=[^' + letterChars + ']?)';

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

6 participants