Class: Banzai::Filter::JiraImport::AdfToCommonmarkFilter

Inherits:
HTML::Pipeline::TextFilter
  • Object
show all
Defined in:
lib/banzai/filter/jira_import/adf_to_commonmark_filter.rb

Overview

Uses Kramdown to convert from the Atlassian Document Format (json) into CommonMark

Instance Method Summary collapse

Constructor Details

#initialize(text, context = nil, result = nil) ⇒ AdfToCommonmarkFilter

Returns a new instance of AdfToCommonmarkFilter.


10
11
12
# File 'lib/banzai/filter/jira_import/adf_to_commonmark_filter.rb', line 10

def initialize(text, context = nil, result = nil)
  super(text, context, result)
end

Instance Method Details

#callObject


14
15
16
17
18
19
20
# File 'lib/banzai/filter/jira_import/adf_to_commonmark_filter.rb', line 14

def call
  Kramdown::Document.new(@text, input: 'AtlassianDocumentFormat', html_tables: true).to_commonmark
rescue ::Kramdown::Error => e
  # If we get an error, then just return the original text so at
  # least the user knows something went wrong
  "#{e.message}\n\n#{@text}"
end