FIX: word boundary regex (\b) not working in Unicode languages. (#9163)

This commit is contained in:
Vinoth Kannan
2020-03-25 18:39:19 +05:30
committed by GitHub
parent 49395ec577
commit 572bb5988f
13 changed files with 175 additions and 161 deletions

View File

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