18F/micropurchase

View on GitHub
app/models/markdown_render.rb

Summary

Maintainability
A
0 mins
Test Coverage
class MarkdownRender
  attr_reader :markdown, :text

  def initialize(text = '')
    @text = text
    @markdown = Redcarpet::Markdown.new(
      Redcarpet::Render::HTML,
      no_intra_emphasis: true,
      autolink: true,
      tables: true,
      fenced_code_blocks: true,
      lax_spacing: true
    )
  end

  def to_s
    markdown.render(text).html_safe
  end
end