Class: Panda::Editor::MarkdownToEditorJsConverter
- Inherits:
-
Object
- Object
- Panda::Editor::MarkdownToEditorJsConverter
- 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
- #convert ⇒ Object
-
#initialize(markdown) ⇒ MarkdownToEditorJsConverter
constructor
A new instance of MarkdownToEditorJsConverter.
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
#convert ⇒ Object
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 |