Module: MaRuKu::Out::HTML

Defined in:
lib/acts_as_markup/exts/maruku.rb

Instance Method Summary collapse

Instance Method Details

#array_to_html(array) ⇒ Object

We patch this method to play nicely with our own modifications of String.

It originally used a to_html method on String we’ve swapped this out for a to_xml method because we need to_html to return the original text on plain text fields of the variable language option on acts_as_markup



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/acts_as_markup/exts/maruku.rb', line 46

def array_to_html(array)
  elements = []
  array.each do |item|
    method = item.kind_of?(MDElement) ? "to_html_#{item.node_type}" : "to_xml"
    unless item.respond_to?(method)
      next
    end

    html_text =  item.send(method)
    if html_text.nil?
      raise "Nil html created by method  #{method}:\n#{html_text.inspect}\n for object #{item.inspect[0,300]}"
    end

    if html_text.kind_of?Array
      elements = elements + html_text
    else
      elements << html_text
    end
  end
  elements
end