module Maildown::MarkdownEngine
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
Public Class Methods
default_html_block()
click to toggle source
# 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()
click to toggle source
# File lib/maildown/markdown_engine.rb, line 55 def self.default_text_block ->(string) { string } end
html_block()
click to toggle source
# File lib/maildown/markdown_engine.rb, line 43 def self.html_block @maildown_markdown_engine_html_block || default_html_block end
set(&block)
click to toggle source
# File lib/maildown/markdown_engine.rb, line 35 def self.set(&block) set_html(&block) end
set_html(&block)
click to toggle source
# File lib/maildown/markdown_engine.rb, line 31 def self.set_html(&block) @maildown_markdown_engine_html_block = block end
set_text(&block)
click to toggle source
# File lib/maildown/markdown_engine.rb, line 39 def self.set_text(&block) @maildown_markdown_engine_text_block = block end
text_block()
click to toggle source
# File lib/maildown/markdown_engine.rb, line 47 def self.text_block @maildown_markdown_engine_text_block || default_text_block end
to_html(string)
click to toggle source
# File lib/maildown/markdown_engine.rb, line 23 def self.to_html(string) html_block.call(string) end
to_text(string)
click to toggle source
# File lib/maildown/markdown_engine.rb, line 27 def self.to_text(string) text_block.call(string) end