Sha256: 800b4f2ec3588063e67ab9335932558c9a0f09cf4166a2ebc1d1a26f1082d96c

Contents?: true

Size: 795 Bytes

Versions: 5

Compression:

Stored size: 795 Bytes

Contents

module MarkdownHelper
  # This method returns the given markdown code rendered as html.
  # Have a look at these sources:
  #   * http://railscasts.com/episodes/272-markdown-with-redcarpet
  #   * https://github.com/vmg/redcarpet
  #   * http://daringfireball.net/projects/markdown/syntax
  #
  def markdown(text, options = nil)
    options ||= { hard_wrap: true, filter_html: true, autolink: true, no_intraemphasis: true, fenced_code: true, gh_blockcode: true }
    Redcarpet::Markdown.new(Redcarpet::Render::HTML, options).render(sanitize(text) || "").html_safe
  end
end

# In order to use the markdown helper method with best_in_place's :display_with argument, 
# the ActionView::Base has to include the markdown method.
#
module ActionView
  class Base
    include MarkdownHelper
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
edit_mode-1.0.5 test_app/app/helpers/markdown_helper.rb
edit_mode-1.0.4 test_app/app/helpers/markdown_helper.rb
edit_mode-1.0.3 test_app/app/helpers/markdown_helper.rb
edit_mode-1.0.2 test_app/app/helpers/markdown_helper.rb
edit_mode-1.0.1 test_app/app/helpers/markdown_helper.rb