Class: DocsKit::MarkdownExport::Blocks
- Inherits:
-
Object
- Object
- DocsKit::MarkdownExport::Blocks
- Defined in:
- lib/docs_kit/markdown_export/blocks.rb
Overview
The Nokogiri → GFM visitor. Splits into two passes over the bounded kit vocabulary: block-level elements (this class) produce Markdown lines separated by blank lines; inline elements (Inline) produce a single run of text. Unknown block elements recurse into their children (text survives, the wrapper is dropped), matching the issue's "recurse into children" rule.
Constant Summary collapse
- HEADINGS =
{ "h1" => "#", "h2" => "##", "h3" => "###", "h4" => "####" }.freeze
- LIST_TAGS =
%w[ul ol].freeze
Instance Method Summary collapse
-
#initialize(export) ⇒ Blocks
constructor
A new instance of Blocks.
-
#render(node) ⇒ Object
Render a container's block children, joined by blank lines.
Constructor Details
Instance Method Details
#render(node) ⇒ Object
Render a container's block children, joined by blank lines. Blocks that yield nothing (whitespace-only text nodes) are dropped so no stray blank lines accumulate.
22 23 24 25 26 |
# File 'lib/docs_kit/markdown_export/blocks.rb', line 22 def render(node) node.children.filter_map { |child| block(child) } .reject(&:empty?) .join("\n\n") end |