Class: Markdownator::Converters::HtmlRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/markdownator/converters/html_renderer.rb

Overview

Walks a Nokogiri HTML node tree and renders Markdown. A focused, dependency-free replacement for reverse_markdown: HTML conversion needs only Nokogiri (which reverse_markdown depended on anyway).

Constant Summary collapse

BLOCK_TAGS =

Elements that introduce their own block (line-separated) content.

%w[
  address article aside blockquote details div dl figcaption figure
  footer form h1 h2 h3 h4 h5 h6 header hr main nav ol p pre section
  table ul
].freeze
SKIP_TAGS =

Elements whose contents are dropped entirely.

%w[script style head title noscript template].freeze

Instance Method Summary collapse

Instance Method Details

#render(node) ⇒ Object



19
20
21
# File 'lib/markdownator/converters/html_renderer.rb', line 19

def render(node)
  blocks_to_string(render_blocks(node))
end