mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FIX: word boundary regex (\b) not working in Unicode languages. (#9163)
This commit is contained in:
@ -2,7 +2,11 @@ import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { isValidLink } from "discourse/lib/click-track";
|
||||
import { number } from "discourse/lib/formatter";
|
||||
import highlightText from "discourse/lib/highlight-text";
|
||||
import highlightSearch from "discourse/lib/highlight-search";
|
||||
import {
|
||||
default as highlightHTML,
|
||||
unhighlightHTML
|
||||
} from "discourse/lib/highlight-html";
|
||||
|
||||
let _decorators = [];
|
||||
|
||||
@ -52,13 +56,13 @@ export default class PostCooked {
|
||||
|
||||
if (highlight && highlight.length > 2) {
|
||||
if (this._highlighted) {
|
||||
$html.unhighlight();
|
||||
unhighlightHTML($html[0]);
|
||||
}
|
||||
|
||||
highlightText($html, highlight, { defaultClassName: true });
|
||||
highlightSearch($html, highlight, { defaultClassName: true });
|
||||
this._highlighted = true;
|
||||
} else if (this._highlighted) {
|
||||
$html.unhighlight();
|
||||
unhighlightHTML($html[0]);
|
||||
this._highlighted = false;
|
||||
}
|
||||
}
|
||||
@ -175,10 +179,8 @@ export default class PostCooked {
|
||||
div.html(result.cooked);
|
||||
_decorators.forEach(cb => cb(div, this.decoratorHelper));
|
||||
|
||||
div.highlight(originalText, {
|
||||
caseSensitive: true,
|
||||
element: "span",
|
||||
className: "highlighted"
|
||||
highlightHTML(div[0], originalText, {
|
||||
matchCase: true
|
||||
});
|
||||
$blockQuote.showHtml(div, "fast", finished);
|
||||
})
|
||||
|
Reference in New Issue
Block a user