Sha256: 768f8d1e621545224b7239865a9252e2c2cd6b3b8a1b651ee2c0bc54f3315b42
Contents?: true
Size: 451 Bytes
Versions: 8
Compression:
Stored size: 451 Bytes
Contents
class MarkdownParser 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_markdown(text) Kramdown::Document.new(text.html_safe, :input => 'html').to_kramdown end def markdown_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