class KramdownParser
Public Class Methods
new(*args)
click to toggle source
# File lib/almanac/MarkdownParser.rb, line 2 def initialize(*args) @attribute = *args[0] end
Public Instance Methods
before_save(record)
click to toggle source
# File lib/almanac/MarkdownParser.rb, line 6 def before_save(record) markdown = Kramdown::Document.new(record.send("#{@attribute}")).to_html record.send("#{@attribute}=", markdown) end
html_to_kramdown(text)
click to toggle source
# File lib/almanac/MarkdownParser.rb, line 11 def html_to_kramdown(text) Kramdown::Document.new(text.html_safe, :input => 'html').to_kramdown end
kramdown_to_html(text)
click to toggle source
# File lib/almanac/MarkdownParser.rb, line 15 def kramdown_to_html(text) Kramdown::Document.new(text.html_safe, :input => 'kramdown').to_html end