Skip to content

Accent Insensitive Highlighting #36

@meunierd

Description

@meunierd

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>';
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions