Class: GfmToBlockkit::Converters::HtmlBlock

Inherits:
Base
  • Object
show all
Defined in:
lib/gfm_to_blockkit/converters/html_block.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
20
21
22
23
24
# File 'lib/gfm_to_blockkit/converters/html_block.rb', line 8

def convert(node)
  content = begin
    node.to_commonmark
  rescue
    ""
  end.chomp
  return [] if content.strip.empty?

  [{
    type: "rich_text",
    elements: [{
      type: "rich_text_preformatted",
      elements: [{type: "text", text: content}],
      border: 0
    }]
  }]
end