Class: GfmToBlockkit::Converters::Paragraph

Inherits:
Base
  • Object
show all
Defined in:
lib/gfm_to_blockkit/converters/paragraph.rb

Instance Method Summary collapse

Methods inherited from Base

converter_for, handles, #initialize, #render_child_as_elements

Constructor Details

This class inherits a constructor from GfmToBlockkit::Converters::Base

Instance Method Details

#convert(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gfm_to_blockkit/converters/paragraph.rb', line 8

def convert(node)
  if standalone_image?(node)
    return Image.new(@context).convert_node(first_image_child(node))
  end

  text = mrkdwn_renderer.render(node)
  return [] if text.strip.empty?

  TextSplitter.split(text).map do |chunk|
    {type: "section", text: {type: "mrkdwn", text: chunk}}
  end
end