Class: BlueDoc::SML::Rules::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/bluedoc/sml/rules/image.rb

Constant Summary

Constants inherited from Base

Base::INDENT_PX

Class Method Summary collapse

Methods inherited from Base

to_text

Class Method Details

.match?(node) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/bluedoc/sml/rules/image.rb', line 5

def self.match?(node)
  tag_name(node) == "image"
end

.to_html(node, opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bluedoc/sml/rules/image.rb', line 9

def self.to_html(node, opts = {})
  attrs = attributes(node)
  attrs[:name] ||= ""

  return attrs[:name] if attrs[:src].blank?

  attr_html = html_attrs(
    src: attrs[:src],
    alt: attrs[:name],
    width: attrs[:width],
    height: attrs[:height]
  )

  %(<img#{attr_html}>)
end