Merge remote-tracking branch 'upstream/master' into toc

Conflicts:
	lib/gollum/frontend/app.rb
	lib/gollum/markup.rb
	test/test_markup.rb
This commit is contained in:
kristi
2012-05-14 09:12:44 -07:00
92 changed files with 8356 additions and 24 deletions
+19 -1
View File
@@ -200,11 +200,29 @@ module Gollum
# Returns the marked up String data.
def process_tags(data)
@tagmap.each do |id, tag|
data.gsub!(id, process_tag(tag))
# If it's preformatted, just put the tag back
if is_preformatted?(data, id)
data.gsub!(id, "[[#{tag}]]")
else
data.gsub!(id, process_tag(tag))
end
end
data
end
# Find `id` within `data` and determine if it's within
# preformatted tags.
#
# data - The String data (with placeholders).
# id - The String SHA1 hash.
PREFORMATTED_TAGS = %w(code tt)
def is_preformatted?(data, id)
doc = Nokogiri::HTML::DocumentFragment.parse(data)
node = doc.search("[text()*='#{id}']").first
node && (PREFORMATTED_TAGS.include?(node.name) ||
node.ancestors.any? { |a| PREFORMATTED_TAGS.include?(a.name) })
end
# Process a single tag into its final HTML form.
#
# tag - The String tag contents (the stuff inside the double