mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
14 lines
260 B
JavaScript
14 lines
260 B
JavaScript
|
export default function(string, regexp) {
|
||
|
if (!regexp) {
|
||
|
return string;
|
||
|
}
|
||
|
|
||
|
if (!(regexp instanceof RegExp)) {
|
||
|
regexp = new RegExp(regexp, 'gi');
|
||
|
}
|
||
|
|
||
|
return m.trust(
|
||
|
$('<div/>').text(string).html().replace(regexp, '<mark>$&</mark>')
|
||
|
);
|
||
|
}
|