Sha256: b5807fd86ac075ff630b6d4c1f70c78f39280d8bbcf218d8f318e7bd3174b7e4

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

class Forest::MarkdownRenderer < Redcarpet::Render::HTML
  def self.options
    {
      autolink: true,
      no_intra_emphasis: true,
      tables: true,
      space_after_headers: true
    }
  end

  def self.render_options
    {
      hard_wrap: true,
      safe_links_only: true
    }
  end

  def postprocess(full_document)
    return full_document if full_document.blank?

    begin
      without_leading_trailing_paragraphs = Regexp.new(/\A<p>(.*)<\/p>\Z/mi).match(full_document)[1]
      unless without_leading_trailing_paragraphs.include?('<p>')
        full_document = without_leading_trailing_paragraphs
      end
    rescue StandardError => e
    end

    Redcarpet::Render::SmartyPants.render(full_document)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forest_cms-0.98.1 app/classes/forest/markdown_renderer.rb