From ed6cbde202a290e3d64e3e86c22b059d8aaab2fe Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 9 May 2017 16:00:17 -0500 Subject: Autolink all of the highlighted text at once --- lib/gitlab/highlight.rb | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index 57ae127254b..da9ac7cc51e 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -69,21 +69,8 @@ module Gitlab end def autolink_strings(highlighted_text) - doc = Nokogiri::HTML::DocumentFragment.parse(highlighted_text) - - # Files without highlighting have all text in `span.line`. - # Files with highlighting have strings and comments in `span`s with a - # `class` starting with `c` or `s`. - doc.xpath('.//span[@class="line" or starts-with(@class, "c") or starts-with(@class, "s")]/text()').each do |node| - content = node.to_html - html = Banzai.render(content, pipeline: :autolink, autolink_emails: true) - - next if html == content - - node.replace(html) - end - - doc.to_html.html_safe + # TODO: Don't run pre-processing pipeline, because this may break the highlighting + Banzai.render(highlighted_text, pipeline: :autolink, autolink_emails: true).html_safe end end end -- cgit v1.2.1