Remove links in code, fixes #128.
This commit is contained in:
+14
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user