fix img vert and horiz align
This commit is contained in:
@@ -80,22 +80,24 @@ module Gollum
|
|||||||
if file = find_file(name)
|
if file = find_file(name)
|
||||||
opts = parse_image_tag_options(tag)
|
opts = parse_image_tag_options(tag)
|
||||||
|
|
||||||
floated = false
|
containered = false
|
||||||
|
|
||||||
classes = [] # applied to whatever the outermost container is
|
classes = [] # applied to whatever the outermost container is
|
||||||
attrs = [] # applied to the image
|
attrs = [] # applied to the image
|
||||||
styles = [] # applied to the image
|
styles = [] # applied to the image
|
||||||
|
|
||||||
|
align = opts['align']
|
||||||
if opts['float']
|
if opts['float']
|
||||||
floated = true
|
containered = true
|
||||||
align = opts['align'] || 'left'
|
align ||= 'left'
|
||||||
if %w{left right}.include?(align)
|
if %w{left right}.include?(align)
|
||||||
classes << "float-#{align};"
|
classes << "float-#{align};"
|
||||||
end
|
end
|
||||||
elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)
|
elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)
|
||||||
attrs << "align=#{align}"
|
attrs << %{align="#{align}"}
|
||||||
elsif align = opts['align']
|
elsif align
|
||||||
if %w{left center right}.include?(align)
|
if %w{left center right}.include?(align)
|
||||||
|
containered = true
|
||||||
classes << "align-#{align}"
|
classes << "align-#{align}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -123,7 +125,7 @@ module Gollum
|
|||||||
style_string = %{ style="#{styles.join(' ')}"}
|
style_string = %{ style="#{styles.join(' ')}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts['frame'] || floated
|
if opts['frame'] || containered
|
||||||
classes << 'frame' if opts['frame']
|
classes << 'frame' if opts['frame']
|
||||||
%{<div class="#{classes.join(' ')}">} +
|
%{<div class="#{classes.join(' ')}">} +
|
||||||
%{<div>} +
|
%{<div>} +
|
||||||
|
|||||||
@@ -70,6 +70,22 @@ context "Markup" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "image with vertical align" do
|
||||||
|
%w{top texttop middle absmiddle bottom absbottom baseline}.each do |align|
|
||||||
|
content = "a [[alpha.jpg|align=#{align}]] b"
|
||||||
|
output = "<p>a <img src=\"/greek/alpha.jpg\" align=\"#{align}\" /> b</p>\n"
|
||||||
|
relative_image(content, output)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "image with horizontal align" do
|
||||||
|
%w{left center right}.each do |align|
|
||||||
|
content = "a [[alpha.jpg|align=#{align}]] b"
|
||||||
|
output = "<p>a <div class=\"align-#{align}\"><div><img src=\"/greek/alpha.jpg\" /></div></div> b</p>\n"
|
||||||
|
relative_image(content, output)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test "image with float" do
|
test "image with float" do
|
||||||
content = "a\n\n[[alpha.jpg|float]]\n\nb"
|
content = "a\n\n[[alpha.jpg|float]]\n\nb"
|
||||||
output = "<p>a</p>\n\n<p><div class=\"float-left;\"><div><img src=\"/greek/alpha.jpg\" /></div></div></p>\n\n<p>b</p>\n"
|
output = "<p>a</p>\n\n<p><div class=\"float-left;\"><div><img src=\"/greek/alpha.jpg\" /></div></div></p>\n\n<p>b</p>\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user