diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index d258c8c5..72eccfb4 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -44,10 +44,14 @@ module Gollum # # Returns the placeholder'd String data. def extract_tags(data) - data.gsub(/\[\[(.+?)\]\]/m) do - id = Digest::SHA1.hexdigest($1) - @tagmap[id] = $1 - id + data.gsub(/(.?)\[\[(.+?)\]\](.?)/m) do + if $1 == "'" && $3 != "'" + "[[#{$2}]]#{$3}" + else + id = Digest::SHA1.hexdigest($2) + @tagmap[id] = $2 + "#{$1}#{id}#{$3}" + end end end diff --git a/test/test_markup.rb b/test/test_markup.rb index 316668c4..d14a5d9a 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -182,6 +182,28 @@ context "Markup" do assert_equal output, rendered end + test "escaped wiki link" do + content = "a '[[Foo]], b" + output = "

a [[Foo]], b

" + compare(content, output) + end + + test "quoted wiki link" do + content = "a '[[Foo]]', b" + output = "

a 'Foo', b

" + compare(content, output) + end + + def compare(content, output) + index = @wiki.repo.index + index.add("Bilbo-Baggins.md", content) + index.commit("Add alpha.jpg") + + page = @wiki.page("Bilbo Baggins") + rendered = Gollum::Markup.new(page).render + assert_equal output, rendered + end + def relative_image(content, output) index = @wiki.repo.index index.add("greek/alpha.jpg", "hi")