Class: Panda::Editor::MarkdownToEditorJsConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/panda/editor/markdown_to_editor_js_converter.rb

Overview

Converts Markdown to EditorJS format Uses Redcarpet to parse markdown to HTML, then converts HTML to EditorJS blocks

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(markdown) ⇒ MarkdownToEditorJsConverter

Returns a new instance of MarkdownToEditorJsConverter.



14
15
16
# File 'lib/panda/editor/markdown_to_editor_js_converter.rb', line 14

def initialize(markdown)
  @markdown = markdown
end

Class Method Details

.convert(markdown) ⇒ Object



10
11
12
# File 'lib/panda/editor/markdown_to_editor_js_converter.rb', line 10

def self.convert(markdown)
  new(markdown).convert
end

Instance Method Details

#convertObject



18
19
20
21
22
23
24
# File 'lib/panda/editor/markdown_to_editor_js_converter.rb', line 18

def convert
  # Step 1: Convert Markdown to HTML using Redcarpet
  html = markdown_to_html

  # Step 2: Convert HTML to EditorJS using existing converter
  Panda::Editor::HtmlToEditorJsConverter.convert(html)
end