Escape lisp-quoted wiki links.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user