Closed nazimcoskun closed 4 years ago
I found a solution using custom template and a regular expression to match the search string and words around it.
template: {
type: "custom",
method: function(value, item) {
regex = new RegExp(/\w*\s*\w*<b>(.*?)<\/b>\w*\s*\w*/g);
value = "... " + value.match(regex) + " ...";
return value;
}
}
Hi,
When searching in a long content, such as a blog post, is it possible to show a truncated search result, instead of the whole content? For instance:
Content: Lorem ipsum dolor sit amet consectetur adipiscing elit.
Search phrase: sit amet
Result to be shown: ... dolor sit amet consectetur ...