summaryrefslogtreecommitdiff
path: root/app/helpers/search_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r--app/helpers/search_helper.rb30
1 files changed, 14 insertions, 16 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index a7acc0cd7db..86012352c8b 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -360,33 +360,31 @@ module SearchHelper
end
end
+ def search_md_sanitize(source)
+ search_sanitize(markdown(search_truncate(source)))
+ end
+
+ def simple_search_highlight_and_truncate(text, phrase, options = {})
+ highlight(search_sanitize(search_truncate(text)), phrase.split, options)
+ end
+
# Sanitize a HTML field for search display. Most tags are stripped out and the
# maximum length is set to 200 characters.
- def search_md_sanitize(source)
- source = Truncato.truncate(
+ def search_truncate(source)
+ Truncato.truncate(
source,
count_tags: false,
count_tail: false,
+ filtered_tags: %w(img),
max_length: 200
)
+ end
- html = markdown(source)
-
+ def search_sanitize(html)
# Truncato's filtered_tags and filtered_attributes are not quite the same
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_issuable(issuable, search_term, _search_highlight)
return unless issuable.description.present?
@@ -406,7 +404,7 @@ module SearchHelper
# Closed is considered "danger" for MR so we need to handle separately
if issuable.is_a?(::MergeRequest)
if issuable.merged?
- :primary
+ :info
elsif issuable.closed?
:danger
else