module MarkdownProcessor
  class << self

    def render_options
      {}
    end

    def markdown_extensions
      {
          no_intra_emphasis: true,
          fenced_code_blocks: true,
          disable_indented_code_blocks: true,
          underline: true,
          highlight: true,
          quote: true,
          autolink: true
      }
    end

    def renderer
      @renderer ||= Redcarpet::Render::SmartyHTML.new(render_options)
    end

    def markdown_obj
      @markdown_obj ||= Redcarpet::Markdown.new(renderer, markdown_extensions)
    end

    def render(text)
      return '' unless text.present?
      markdown_obj.render(text)
    end

  end
end