Fix #537
This commit is contained in:
@@ -520,9 +520,15 @@ module Gollum
|
|||||||
id = Digest::SHA1.hexdigest("#{lang}.#{m_code}")
|
id = Digest::SHA1.hexdigest("#{lang}.#{m_code}")
|
||||||
cached = check_cache(:code, id)
|
cached = check_cache(:code, id)
|
||||||
|
|
||||||
|
# extract lang from { .ruby } or { #stuff .ruby .indent }
|
||||||
|
# see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
|
||||||
|
|
||||||
|
lang = lang.match(/\.([^}\s]+)/)
|
||||||
|
lang = lang[1] unless lang.nil?
|
||||||
|
|
||||||
@codemap[id] = cached ?
|
@codemap[id] = cached ?
|
||||||
{ :output => cached } :
|
{ :output => cached } :
|
||||||
{ :lang => lang.gsub(/[{}\.]/, '').strip, :code => m_code, :indent => m_indent }
|
{ :lang => lang, :code => m_code, :indent => m_indent }
|
||||||
|
|
||||||
"#{m_indent}#{id}" # print the SHA1 ID with the proper indentation
|
"#{m_indent}#{id}" # print the SHA1 ID with the proper indentation
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -224,6 +224,18 @@ context "Markup" do
|
|||||||
assert_equal expected, output
|
assert_equal expected, output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "~~~ code blocks #537 with more than one class" do
|
||||||
|
page = 'test_rgx'
|
||||||
|
@wiki.write_page(page, :markdown,
|
||||||
|
%Q(~~~ {#hi .ruby .sauce}
|
||||||
|
'hi'
|
||||||
|
~~~
|
||||||
|
), commit_details)
|
||||||
|
output = @wiki.page(page).formatted_data
|
||||||
|
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||||
|
assert_equal expected, output
|
||||||
|
end
|
||||||
|
|
||||||
test "wiki link within code block" do
|
test "wiki link within code block" do
|
||||||
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
|
|||||||
Reference in New Issue
Block a user