From 8595ca5645ee9474ecc03924b2a5ed09f80c114c Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 20 Jul 2010 22:22:22 -0500 Subject: [PATCH] Fix tests and handle touching tags. --- lib/gollum/markup.rb | 2 +- test/test_markup.rb | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index afacbbea..5229d8e0 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -44,7 +44,7 @@ module Gollum # # Returns the placeholder'd String data. def extract_tags(data) - data.gsub(/(.?)\[\[(.+?)\]\](.?)/m) do + data.gsub(/(.?)\[\[(.+?)\]\]([^\[]?)/m) do if $1 == "'" && $3 != "'" "[[#{$2}]]#{$3}" elsif $2.include?('][') diff --git a/test/test_markup.rb b/test/test_markup.rb index d14a4ef5..93c8b2c7 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -16,11 +16,25 @@ context "Markup" do FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w[examples test.git])) end + test "double page links no space" do + @wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", @commit) + + page = @wiki.page("Bilbo Baggins") + assert_equal "

a FooBar b

", page.formatted_data + end + + test "double page links with space" do + @wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]] [[Bar]] b", @commit) + + page = @wiki.page("Bilbo Baggins") + assert_equal "

a Foo Bar b

", page.formatted_data + end + test "page link" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Bilbo Baggins]] b", @commit) page = @wiki.page("Bilbo Baggins") - output = Gollum::Markup.new(page).render + output = page.formatted_data assert_match /class="internal present"/, output assert_match /href="\/Bilbo-Baggins"/, output assert_match /\>Bilbo Baggins\J\. R\. R\. Tolkien\Bilbo Baggins\a b

}, output end end @@ -67,8 +81,7 @@ context "Markup" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[/alpha.jpg]] [[a | /alpha.jpg]] b", @commit) page = @wiki.page("Bilbo Baggins") - output = Gollum::Markup.new(page).render - assert_equal %{

a a b

}, output + assert_equal %{

a a b

}, page.formatted_data end test "image with relative path on root" do @@ -79,8 +92,7 @@ context "Markup" do index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") - output = Gollum::Markup.new(page).render - assert_equal %{

a a b

}, output + assert_equal %{

a a b

}, page.formatted_data end test "image with relative path" do @@ -91,8 +103,8 @@ context "Markup" do index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") - output = Gollum::Markup.new(page).render - assert_equal %{

a a b

}, output + output = page.formatted_data + assert_equal %{

a a b

}, output end test "image with alt" do