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

Version Path
almanac-0.6.1 lib/almanac/MarkdownParser.rb
almanac-0.6.0 lib/almanac/MarkdownParser.rb
almanac-0.5.3 lib/almanac/MarkdownParser.rb
almanac-0.5.2 lib/almanac/MarkdownParser.rb
almanac-0.5.1 lib/almanac/MarkdownParser.rb
almanac-0.5.0 lib/almanac/MarkdownParser.rb
almanac-0.4.5 lib/almanac/MarkdownParser.rb
almanac-0.4.4 lib/almanac/MarkdownParser.rb