twitter-bootstrap-typeahead icon indicating copy to clipboard operation
twitter-bootstrap-typeahead copied to clipboard

Accent Insensitive Highlighting

Open meunierd opened this issue 12 years ago • 6 comments

I'd love for accent insensitive highlighting to be baked in the same way case insensitivity is. I'm currently using the following for French, and I'm not sure how it would generalize:

highlighter: function(item) {
  var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
  // French accent insensitivity
  // ---------------------------------------
  query = query.replace(/a/i, '[aáÁàÀâÂäÄ]');
  query = query.replace(/e/i, '[eéÉèÈêÊëË]');
  query = query.replace(/i/i, '[iíÍìÌîÎïÏ]');
  query = query.replace(/o/i, '[oóÓòÒôÔöÖ]');
  query = query.replace(/u/i, '[uúÚùÙûÛüÜ]');
  query = query.replace(/c/i, '[cçÇ]');
  // ----------------------------------------
  return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
    return '<strong>' + match + '</strong>';
  });
}

meunierd avatar Jan 29 '13 20:01 meunierd

+1

Bensk1 avatar Aug 27 '13 06:08 Bensk1

+1

fardus avatar Oct 24 '13 06:10 fardus

+1

zgababa avatar Mar 10 '15 16:03 zgababa

+1

TravnikovDev avatar Apr 01 '15 15:04 TravnikovDev

Do you know how to adapt this "hack" to https://github.com/bassjobsen/Bootstrap-3-Typeahead

bklups avatar Jun 25 '15 12:06 bklups

@bklups please check this out http://stackoverflow.com/questions/22460272/typeahead-insensitive-accent/35247090#35247090

ghost avatar Feb 07 '16 01:02 ghost