Sha256: e29f6b5875cb5bbee09a8e91efd22c17c161ba6694302b5e846e523fc4226309
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
require 'administrate/field/text' require 'administrate/engine' require 'redcarpet/render_strip' module Administrate module Field class SimpleMarkdown < Administrate::Field::Text class Engine < ::Rails::Engine Administrate::Engine.add_javascript 'administrate-field-simple_markdown/application' Administrate::Engine.add_stylesheet 'administrate-field-simple_markdown/application' end def to_html markdown(html_renderer).render(data).html_safe end def to_s markdown(plaintext_renderer).render(data) end private def html_renderer @html_renderer ||= Redcarpet::Render::HTML.new({ safe_links_only: true, filter_html: true, with_toc_data: true, hard_wrap: true, link_attributes: { rel: 'nofollow' } }) end def plaintext_renderer @plaintext_renderer ||= Redcarpet::Render::StripDown end def markdown(renderer) @markdown ||= Redcarpet::Markdown.new(renderer, { autolink: true, tables: true, no_intra_emphasis: true, strikethrough: true, highlight: true, space_after_headers: true }) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems