This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/lib/highlight-text.js.es6
2018-06-15 17:03:24 +02:00

9 lines
344 B
JavaScript

export default function($elem, term) {
if (!_.isEmpty(term)) {
// special case ignore "l" which is used for magic sorting
let words = _.reject(term.match(/"[^"]+"|[^\s]+/g), t => t === "l");
words = words.map(w => w.replace(/^"(.*)"$/, "$1"));
$elem.highlight(words, { className: "search-highlight", wordsOnly: true });
}
}