Module: Asciidoctor::Html::Figure
- Included in:
- Converter
- Defined in:
- lib/asciidoctor/html/figure.rb
Overview
Helper functions for the image/figure conversion. Mixed into the Converter class.
Instance Method Summary collapse
- #convert_figlist(node) ⇒ Object
- #display_figure(node) ⇒ Object
- #display_image(node, target, attrs) ⇒ Object
- #image_attrs(node) ⇒ Object
Instance Method Details
#convert_figlist(node) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/asciidoctor/html/figure.rb', line 30 def convert_figlist(node) result = node.items.map do |item| %(<li#{Utils.id_class_attr_str item.id}><figure>\n#{item.text}\n</figure></li>) end content = Utils.wrap_id_classes result.join("\n"), nil, "figlist loweralpha", :ol title = Utils.display_title node classes = ["figlist-wrapper", node.role].compact.join(" ") Utils.wrap_id_classes %(#{content}#{title}), node.id, classes end |
#display_figure(node) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/asciidoctor/html/figure.rb', line 21 def display_figure(node) target = node.attr "target" title = node.title? ? node.title : "" attrs = image_attrs node image = display_image node, target, attrs caption = %(<figcaption>#{Utils.display_title_prefix node}#{title}</figcaption>) %(<figure>\n #{image}\n #{caption}\n</figure>) end |
#display_image(node, target, attrs) ⇒ Object
10 11 12 |
# File 'lib/asciidoctor/html/figure.rb', line 10 def display_image(node, target, attrs) %(<img src="#{node.image_uri target}" #{attrs}#{@void_element_slash}>) end |
#image_attrs(node) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/asciidoctor/html/figure.rb', line 14 def image_attrs(node) width = node.attr?("width") ? %( width="#{node.attr "width"}") : "" height = node.attr?("height") ? %( height="#{node.attr "height"}") : "" alt = encode_attribute_value node.alt %(alt="#{alt}"#{width}#{height}) end |