He there! In my installation of Discourse 2.5.0.beta1 there is not working highlighting searched keywords in search results if search was done in other than english.
Is it a bug or a feature?)
Thanks
AI-generated summary
Search results highlighting issue in non-English languages
@smith reported that search results are not highlighting keywords in languages other than English. @sam explained that Discourse only highlights complete words, but @smith provided examples showing that this is not working as expected.
@sam suspected a bug in the highlighting JavaScript library and asked for the exact non-English word to investigate. @smith provided an example in Cyrillic, prompting @vinothkannans to identify the issue in the jQuery Highlight plugin. The problem lies in the plugin’s use of word boundary regex (\b), which is not supported in Unicode characters.
@vinothkannans proposed a possible solution using a different regex pattern. @sam cautioned that any fix should prioritize performance, especially in cases with long text or non-Latin characters. @vinothkannans created a pull request with the proposed fix.
What is expected here @sam?
We only highlight complete words. This looks like a partial word.
@vinothkannans can you have a quick look at:
@smith can you make a post here with the exact Greek word? (I think this is Greek) this could be a bug in our highlighting Javascript library.
For it has seemed good to the Holy Spirit and to us to lay on you no greater burden than these necessary things: to abstain from things offered to idols, from blood, from things strangled, and from sexual immorality. If you keep yourselves from these, you will do well. Farewell.
The issue is in the jQuery Highlight plugin. To highlight the words it’s using the word boundary \b regex which is not supported in Unicode characters.
https://medium.com/@shiba1014/regex-word-boundaries-with-unicode-207794f6e7ed
(?<=[\s,.:;"']|^)UNICODE_WORD(?=[\s,.:;"']|$)
It looks like a possible solution ![]()
I think @gerhard dealt with this particular issue with unicode usernames (at least I vaguely recall)
Super happy to see a fix here, but we got to be ultra careful that whatever regex we choose does not have pathologically bad performance in certain cases where text is long or particularly bad. Also I think in Chinese we don’t even care about word boundaries?
Created a new PR with the fix


