Remove links in code, fixes #128.

This commit is contained in:
Jonathan Roes
2012-05-11 22:49:26 -04:00
parent c428cad286
commit eb37b17486
2 changed files with 30 additions and 5 deletions
+14 -2
View File
@@ -53,9 +53,12 @@ module Gollum
end
data = process_tags(data)
data = process_code(data, encoding)
doc = Nokogiri::HTML::DocumentFragment.parse(data)
doc = remove_links_in_code(doc)
if sanitize || block_given?
doc = Nokogiri::HTML::DocumentFragment.parse(data)
doc = sanitize.clean_node!(doc) if sanitize
doc = sanitize.clean_node!(doc) if sanitize
yield doc if block_given?
data = doc.to_html
end
@@ -353,6 +356,15 @@ module Gollum
end
end
def remove_links_in_code(doc)
doc.css('code > a').each do |link|
link.before("[[#{link.content}]]")
link.remove
end
doc
end
#########################################################################
#
# Code