I’m in a similar situation. I’ve been trying for quite some time to replicate the highlighting functionality. Here’s what I’ve found.
There is an obfuscated function called $P (Around line 58323) applies a span to the text to highlight with the CSS class ‘search-result-file-matched-text’. I’ve tried for weeks to replicate the logic in the call stack to $P but haven’t been successful.
The official API exposes ‘renderMatches’ and ‘renderResults’. Both apply a class to matches within a string but they don’t apply the ‘search-result-file-matched-text’ class. I assume it’s different logic then.
Have you found anything of substance? I haven’t had any luck.