Class: Detergent::MarkdownRenderer
- Inherits:
-
Object
- Object
- Detergent::MarkdownRenderer
- Defined in:
- lib/detergent/markdown_renderer.rb
Overview
Renders a cleaned content node as Markdown. Expects the article-shaped markup that comes out of extraction; it is not a general-purpose HTML-to-Markdown converter.
The formatting decisions live in small hook methods (heading, link, image, ...) so TextRenderer can subclass this and strip the syntax.
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#render(node) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/detergent/markdown_renderer.rb', line 11 def render(node) # Route through render_block so a root that is itself a block # element (a ul, a blockquote) gets its block treatment; generic # containers and fragments fall through to render_blocks. output = node.element? ? render_block(node) : render_blocks(node) output.gsub(/\n{3,}/, "\n\n").strip end |