Sha256: d3e49de815de1f0e60ddcc48d2b186e01c7400733788853ebeb316d2a70560e5
Contents?: true
Size: 451 Bytes
Versions: 8
Compression:
Stored size: 451 Bytes
Contents
class KramdownParser def initialize(*args) @attribute = *args[0] end def before_save(record) markdown = Kramdown::Document.new(record.send("#{@attribute}")).to_html record.send("#{@attribute}=", markdown) end def html_to_kramdown(text) Kramdown::Document.new(text.html_safe, :input => 'html').to_kramdown end def kramdown_to_html(text) Kramdown::Document.new(text.html_safe, :input => 'kramdown').to_html end end
Version data entries
8 entries across 8 versions & 1 rubygems