Class: GfmToBlockkit::Converter
- Inherits:
-
Object
- Object
- GfmToBlockkit::Converter
- Defined in:
- lib/gfm_to_blockkit/converter.rb
Constant Summary collapse
- MAX_BLOCKS =
50
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(markdown, table_format: :preformatted) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(markdown, table_format: :preformatted) ⇒ Converter
Returns a new instance of Converter.
9 10 11 12 13 14 15 16 |
# File 'lib/gfm_to_blockkit/converter.rb', line 9 def initialize(markdown, table_format: :preformatted) @markdown = markdown @context = Context.new( mrkdwn_renderer: Renderers::Mrkdwn.new, rich_text_renderer: Renderers::RichText.new, table_format: table_format ) end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/gfm_to_blockkit/converter.rb', line 18 def call return [] if @markdown.nil? || @markdown.strip.empty? doc = Commonmarker.parse(@markdown, options: ) blocks = [] doc.each { |node| blocks.concat(convert_block(node)) } blocks.take(MAX_BLOCKS) end |