- def self.html_parser
- @html_parser ||= Redcarpet::Markdown.new(html_renderer, :no_intra_emphasis => true, :autolink => true, :space_after_headers => true)
+ private
+
+ def document
+ @document ||= Kramdown::Document.new(self)
+ end
+
+ def first_image_element(element)
+ return element if element.type == :img
+
+ element.children.find do |child|
+ nested_image = first_image_element(child)
+ break nested_image if nested_image
+ end