Module: Maildown::MarkdownEngine
- Defined in:
- lib/maildown/markdown_engine.rb
Overview
This module provides the API for Replacing the Markdown engine
Maildown uses [kramdown](github.com/gettalong/kramdown) by default. Kramdown is pure ruby, so it runs the same across all ruby implementations: jruby, rubinius, MRI, etc. You can configure another parser if you like using the ‘Maildown::MarkdownEngine.set_html` method and pasing it a block.
For example, if you wanted to use Redcarpet you could set it like this:
Maildown::MarkdownEngine.set_html do |text|
carpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {})
carpet.render(text).html_safe
end
Class Method Summary collapse
- .default_html_block ⇒ Object
- .default_text_block ⇒ Object
- .html_block ⇒ Object
- .set(&block) ⇒ Object
- .set_html(&block) ⇒ Object
- .set_text(&block) ⇒ Object
- .text_block ⇒ Object
- .to_html(string) ⇒ Object
- .to_text(string) ⇒ Object
Class Method Details
.default_html_block ⇒ Object
51 52 53 |
# File 'lib/maildown/markdown_engine.rb', line 51 def self.default_html_block ->(string) { Kramdown::Document.new(string, input: "GFM").to_html } end |
.default_text_block ⇒ Object
55 56 57 |
# File 'lib/maildown/markdown_engine.rb', line 55 def self.default_text_block ->(string) { string } end |
.html_block ⇒ Object
43 44 45 |
# File 'lib/maildown/markdown_engine.rb', line 43 def self.html_block @maildown_markdown_engine_html_block || default_html_block end |
.set(&block) ⇒ Object
35 36 37 |
# File 'lib/maildown/markdown_engine.rb', line 35 def self.set(&block) set_html(&block) end |
.set_html(&block) ⇒ Object
31 32 33 |
# File 'lib/maildown/markdown_engine.rb', line 31 def self.set_html(&block) @maildown_markdown_engine_html_block = block end |
.set_text(&block) ⇒ Object
39 40 41 |
# File 'lib/maildown/markdown_engine.rb', line 39 def self.set_text(&block) @maildown_markdown_engine_text_block = block end |
.text_block ⇒ Object
47 48 49 |
# File 'lib/maildown/markdown_engine.rb', line 47 def self.text_block @maildown_markdown_engine_text_block || default_text_block end |
.to_html(string) ⇒ Object
23 24 25 |
# File 'lib/maildown/markdown_engine.rb', line 23 def self.to_html(string) html_block.call(string) end |
.to_text(string) ⇒ Object
27 28 29 |
# File 'lib/maildown/markdown_engine.rb', line 27 def self.to_text(string) text_block.call(string) end |