diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-09 16:00:17 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-12 15:12:48 -0500 |
commit | ed6cbde202a290e3d64e3e86c22b059d8aaab2fe (patch) | |
tree | 37b43e0978f95c1d7b928b1ff01a2cd592dab058 | |
parent | 625ce63c7d5b7ff81a119ea237b244f0cb5beed7 (diff) | |
download | gitlab-ce-ed6cbde202a290e3d64e3e86c22b059d8aaab2fe.tar.gz |
Autolink all of the highlighted text at once
-rw-r--r-- | lib/gitlab/highlight.rb | 17 |
1 files 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 |