Escape lisp-quoted wiki links.

This commit is contained in:
Tom Preston-Werner
2010-07-08 19:04:36 -07:00
parent 9e3a307aa8
commit 2c2bf68a3b
2 changed files with 30 additions and 4 deletions
+8 -4
View File
@@ -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
+22
View File
@@ -182,6 +182,28 @@ context "Markup" do
assert_equal output, rendered
end
test "escaped wiki link" do
content = "a '[[Foo]], b"
output = "<p>a [[Foo]], b</p>"
compare(content, output)
end
test "quoted wiki link" do
content = "a '[[Foo]]', b"
output = "<p>a '<a class=\"internal absent\" href=\"Foo\">Foo</a>', b</p>"
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")