diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-08 18:08:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-08 18:08:17 +0300 |
commit | 1ec1bec4ee7ef7cb2e6faa7af625950f6d7aa290 (patch) | |
tree | 515047b93cfb054156b99c612684eb9a4c45330d /app/helpers/search_helper.rb | |
parent | 2f5c5b1081fe544ecb9a71d8adf88e00f01f3732 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r-- | app/helpers/search_helper.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index e0dbd33b5d2..63601485daf 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -301,8 +301,21 @@ module SearchHelper sanitize(html, tags: %w(a p ol ul li pre code)) end + def simple_search_highlight_and_truncate(text, phrase, options = {}) + text = Truncato.truncate( + text, + count_tags: false, + count_tail: false, + max_length: options.delete(:length) { 200 } + ) + + highlight(text, phrase.split, options) + end + # _search_highlight is used in EE override def highlight_and_truncate_issue(issue, search_term, _search_highlight) + return unless issue.description.present? + simple_search_highlight_and_truncate(issue.description, search_term, highlighter: '<span class="gl-text-black-normal gl-font-weight-bold">\1</span>') end |