diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb
index 27ed110f..344993e5 100644
--- a/lib/gollum/markup.rb
+++ b/lib/gollum/markup.rb
@@ -78,10 +78,31 @@ module Gollum
name = parts[0].strip
if file = find_file(name)
- %{}
+ attrs = process_image_tag_attributes(tag)
+ %{
}
end
end
+ # Process any attributes present on the image tag and format them as an
+ # image tag fragment.
+ #
+ # tag - The String tag contents (the stuff inside the double brackets).
+ #
+ # Returns the String image tag fragment.
+ def process_image_tag_attributes(tag)
+ attrs = tag.split('|')[1..-1].inject({}) do |memo, attr|
+ parts = attr.split('=').map { |x| x.strip }
+ memo[parts[0]] = (parts.size == 1 ? true : parts[1])
+ memo
+ end
+
+ fragments = []
+ if alt = attrs['alt']
+ fragments << %{alt="#{alt}"}
+ end
+ fragments.size > 0 ? fragments.join(' ') + ' ' : ''
+ end
+
# Attempt to process the tag as a file link tag.
#
# tag - The String tag contents (the stuff inside the double brackets).
diff --git a/test/test_markup.rb b/test/test_markup.rb
index da07578c..62acdbb6 100644
--- a/test/test_markup.rb
+++ b/test/test_markup.rb
@@ -46,6 +46,12 @@ context "Markup" do
assert_equal %{
a
b
a
b
a Alpha b
\n}, output end -end + def relative_image(content, output) + index = @wiki.repo.index + index.add("greek/alpha.jpg", "hi") + index.add("greek/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 +end \ No newline at end of file