mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 13:05:50 +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>')
|
||
|
);
|
||
|
}
|