FIX: remove word boundary regex (\b) for search result highlights. (PR #9338)

And removed the jQuery Highlight plugin and created a new es6 highlighting library.


The title of this pull request changed from “FIX: word boundary regex (\b) not working in Unicode languages.” to "FIX: remove word boundary regex (\b) for search result highlights.

Could we try to avoid using jquery while we are at it ? I see highlight-html is using the node and not jquery object.

Screenshot 2020-04-03 at 15 21 16

We have makeArray for this pattern

I think it’s better to do this:

settings = Object.assign({}, settings, opts);

This way you don’t rely on an implicit mutation of setting but create a new object instead, much more explicit.

should be called through an import

could we use element instead of e here please?

probably worth having a variable with a good name, instead of reach for $html[0] each time

Only added few minor comments @vinothkannans , seems very good to me :+1: But I think robin should have a look at this too, so I added him.

Renaming highlight-text to highlight-search will break at least two themes in our repos. Is there a way you can add backwards compatibility with a deprecation?

sure :+1:

Looks good to me now, thanks @vinothkannans

@eviltrout @vinothkannans Just a heads up, this broke a theme component for me today, because the component was loading discourse/lib/highlight-text which is now no longer included. The good news is that file doesn’t seem to be imported in too many themes/plugins.

@pmusaraj previously, highlight-text was in both lib and component folders. I added backward compatibility only for the component file since we’re using it in ember templates. I will add backward compatibility for lib file too if it’s going to break more than one theme/plugin.