diff --git a/public/src/admin/modules/search.js b/public/src/admin/modules/search.js index 0a5d3dde56..c7f660149a 100644 --- a/public/src/admin/modules/search.js +++ b/public/src/admin/modules/search.js @@ -19,11 +19,16 @@ define(function () { var title = params.title == null ? nsToTitle(namespace) : params.title; var results = translations + // remove all lines without a match .replace(new RegExp('^(?:(?!' + term + ').)*$', 'gmi'), '') + // get up to 25 characaters of context on both sides of the match + // and wrap the match in a `.search-match` element .replace( new RegExp('^[\\s\\S]*?(.{0,25})(' + term + ')(.{0,25})[\\s\\S]*?$', 'gmi'), '...$1$2$3...
' - ).replace(/(\n ?)+/g, '\n'); + ) + // collapse whitespace + .replace(/(?:\n ?)+/g, '\n'); return '