sourish-rygbee / jquery-spellchecker

Automatically exported from code.google.com/p/jquery-spellchecker
0 stars 0 forks source link

First and last word of HTML fields are not highlighted when misspelled #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add spellchecker to an HTML field with word highlighting enabled and the 
first and last word misspelled

What is the expected output? What do you see instead?
The misspelled words, when first or last are not highlighted nor are the links 
enabled.

What version of the product are you using? On what operating system?
I am using the most recent revision on Firefox 3.6 and IE7.

Please provide any additional information below.
Its because the regular expression used for highlighting only matches words 
with spaces on either side. I changed it to match whether the spaces are there 
or not:
97: new RegExp('(\s)*('+replaceWord+')(\s)*','g'),

Original issue reported on code.google.com by gustaf...@gmail.com on 20 Aug 2010 at 10:02

GoogleCodeExporter commented 9 years ago
I don't believe matching whether or not there are spaces is a complete 
solution. Consider a word that is encased in parentheses. 

To get around this issue I left the regular expression alone and instead padded 
the variable "html" on line 97 with spaces and then removed them after the 
replace function finished. This may not be 100% correct either but it does 
catch words that are encased in characters like parentheses, and it does catch 
the words at the start and end of the string.

Original comment by Matthew....@gmail.com on 1 Sep 2011 at 4:54

GoogleCodeExporter commented 9 years ago
Rather than padding the text, I added two more replace calls instead catering 
for the occurrence of the replaceText in the front and the back.

html.replace(new 
RegExp('([^a-zA-Z\\u00A1-\\uFFFF])('+replaceWord+')([^a-zA-Z\\u00A1-\\uFFFF])', 
'g'), '$1<span class="spellcheck-word-highlight">$2</span>$3')
.replace(new RegExp('([^a-zA-Z\\u00A1-\\uFFFF])('+replaceWord+')$', 'g'), 
'$1<span class="spellcheck-word-highlight">$2</span>')
.replace(new RegExp('^('+replaceWord+')([^a-zA-Z\\u00A1-\\uFFFF])', 'g'), 
'<span class="spellcheck-word-highlight">$1</span>$2');

Original comment by brinley on 3 Aug 2012 at 6:20

GoogleCodeExporter commented 9 years ago
This issue is fixed in the latest version of the plugin, which can be found 
here: https://github.com/badsyntax/jquery-spellchecker

You can test this issue here: http://jquery-spellchecker-demo/redactor.html

Original comment by willis...@gmail.com on 2 Nov 2012 at 8:40

GoogleCodeExporter commented 9 years ago
Woops, that link should be: 
http://jquery-spellchecker.badsyntax.co/redactor.html

Original comment by willis...@gmail.com on 2 Nov 2012 at 8:40

GoogleCodeExporter commented 9 years ago
http://jquery-spellchecker.badsyntax.co/tinymce.html

This issue still appears here when using jquery spell checker with tinymce

Original comment by thota.v....@gmail.com on 13 Mar 2013 at 5:11

GoogleCodeExporter commented 9 years ago
This issue is not fixed for tinymce, when we added invalid words at begining 
and ending of the text in tinymce. Please advice.

Original comment by thota.v....@gmail.com on 13 Mar 2013 at 6:29

GoogleCodeExporter commented 9 years ago
This issue was fixed at the time of writing. I've since introduced a regression 
bug. This regression bug is fixed in the latest development version and I'm yet 
to release the fix. I will set up a dev site so you can test the development 
changes. I'll update this ticket..

Original comment by willis...@gmail.com on 13 Mar 2013 at 9:54

GoogleCodeExporter commented 9 years ago
You can test the latest version here: 
http://dev.jquery-spellchecker.badsyntax.co/tinymce.html

Original comment by willis...@gmail.com on 13 Mar 2013 at 10:09