From 114961865392239de2e8ce0ab9ff0d8522685266 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 13 Oct 2012 19:53:41 -0600 Subject: [PATCH] Fix #537 --- lib/gollum/markup.rb | 8 +++++++- test/test_markup.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 00bca913..ea1b8a27 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -520,9 +520,15 @@ module Gollum id = Digest::SHA1.hexdigest("#{lang}.#{m_code}") 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 ? { :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 end diff --git a/test/test_markup.rb b/test/test_markup.rb index dcac3dfa..09b51ddc 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -224,6 +224,18 @@ context "Markup" do assert_equal expected, output 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{
'hi'\n
} + assert_equal expected, output + end + test "wiki link within code block" do @wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details) page = @wiki.page("Potato")