fix for bug29371 . regex wordwrap with UTF8: do not use \b metacharacter. The problem...
authorThomas Gries <wikinaut@users.mediawiki.org>
Tue, 14 Jun 2011 21:42:25 +0000 (21:42 +0000)
committerThomas Gries <wikinaut@users.mediawiki.org>
Tue, 14 Jun 2011 21:42:25 +0000 (21:42 +0000)
resources/jquery/jquery.autoEllipsis.js
resources/jquery/jquery.highlightText.js
resources/jquery/jquery.suggestions.js

index 6253310..7d72689 100644 (file)
@@ -5,7 +5,7 @@
 
 // Cache ellipsed substrings for every string-width-position combination
 var cache = { };
-// Use a seperate cache when match highlighting is enabled
+// Use a separate cache when match highlighting is enabled
 var matchTextCache = { };
 
 $.fn.autoEllipsis = function( options ) {
index 7ca29ef..4bc231c 100644 (file)
@@ -21,9 +21,10 @@ $.highlightText = {
                // if this is a text node
                if ( node.nodeType == 3 ) {
                        // TODO - need to be smarter about the character matching here. 
-                       // non latin characters can make regex think a new word has begun. 
-                       // look for an occurence of our pattern and store the starting position 
-                       var pos = node.data.search( new RegExp( "\\b" + $.escapeRE( pat ), "i" ) );
+                       // non latin characters can make regex think a new word has begun: do not use \b
+                       // http://stackoverflow.com/questions/3787072/regex-wordwrap-with-utf8-characters-in-js
+                       // look for an occurence of our pattern and store the starting position
+                       var pos = node.data.search( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) );
                        if ( pos >= 0 ) {
                                // create the span wrapper for the matched text
                                var spannode = document.createElement( 'span' );
index d3f294f..90cf53b 100644 (file)
@@ -229,7 +229,7 @@ $.suggestions = {
                                } else {
                                        result = selected.prev();
                                        if ( selected.length == 0 ) {
-                                               // we are at the begginning, so lets jump to the last item
+                                               // we are at the beginning, so lets jump to the last item
                                                if ( context.data.$container.find( '.suggestions-special' ).html() != "" ) {
                                                        result = context.data.$container.find( '.suggestions-special' );
                                                } else {