Method: MaRuKu::Out::HTML#array_to_html

Defined in:
lib/maruku/output/to_html.rb

#array_to_html(array) ⇒ Object



868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
# File 'lib/maruku/output/to_html.rb', line 868

def array_to_html(array)
  e = []
  array.each do |c|
    if c.kind_of?(String)
      e << xtext(c)
    else
      if c.kind_of?(HTMLElement)
        e << c
        next
      end

      method = c.kind_of?(MaRuKu::MDElement) ? "to_html_#{c.node_type}" : "to_html"
      next unless c.respond_to?(method)

      h = c.send(method)

      unless h
        raise "Nil html created by method  #{method}:\n#{h.inspect}\n" +
          " for object #{c.inspect[0,300]}"
      end

      if h.kind_of? Array
        e.concat h
      else
        e << h
      end
    end
  end
  e
end