Skip to content

Commit

Permalink
Merge pull request #2 from ajitredhat/main
Browse files Browse the repository at this point in the history
Added support for additional attributes in convert_image.
  • Loading branch information
jhradilek committed Jul 9, 2024
2 parents f8edbf5 + 52589b0 commit 9db6eef
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/dita-topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,31 @@ def convert_floating_title node
end

# FIXME: Add support for additional attributes.
def convert_image node
# Check if the image has a title specified:
def convert_image(node)
# Check if scale, height, and width exist
scale = node.attr('scale') || 100
height = node.attr('height')
width = node.attr('width')

# Construct the attributes string based on if scale, height, and width exist
attributes = "scale=\"#{scale}\""
attributes += " height=\"#{height}\"" if height
attributes += " width=\"#{width}\"" if width

# Check if the image has a title specified
if node.title?
<<~EOF.chomp
<fig>
<title>#{node.title}</title>
<image href="#{node.image_uri(node.attr 'target')}" placement="break">
<alt>#{node.alt}</alt>
</image>
<title>#{node.title}</title>
<image href="#{node.image_uri(node.attr 'target')}" placement="break" #{attributes}>
<alt>#{node.alt}</alt>
</image>
</fig>
EOF
else
<<~EOF.chomp
<image href="#{node.image_uri(node.attr 'target')}" placement="break">
<alt>#{node.alt}</alt>
<image href="#{node.image_uri(node.attr 'target')}" placement="break" #{attributes}>
<alt>#{node.alt}</alt>
</image>
EOF
end
Expand Down

0 comments on commit 9db6eef

Please sign in to comment.