Sha256: 7cf810fd20687eb86d9a1772a570a36d01e87672ba555d32cdad07939da24341

Contents?: true

Size: 1.01 KB

Versions: 74

Compression:

Stored size: 1.01 KB

Contents

require 'redcarpet'

module Playbook
  module Markdown
    class HTMLWithPants < Redcarpet::Render::HTML
      include Redcarpet::Render::SmartyPants
    end

    class TemplateHandler
      class_attribute :default_format
      self.default_format = Mime[:html]

      class << self
        def call(template)
          compiled_source = erb.call(template)
          "#{name}.render(begin;#{compiled_source};end)"
        end

        def render(template)
          markdown.render(template).html_safe
        end

        private

        def md_options
          @md_options ||= {
            autolink: true,
            no_intra_emphasis: true,
            fenced_code_blocks: true,
            strikethrough: true,
            tables: true,
          }
        end

        def markdown
          @markdown ||= Redcarpet::Markdown.new(::Playbook::Markdown::HTMLWithPants, md_options)
        end

        def erb
          @erb ||= ActionView::Template.registered_template_handler(:erb)
        end
      end
    end
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
playbook_ui-9.10.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.10.0.pre.date.time.stacked.1 lib/playbook/markdown/template_handler.rb
playbook_ui-9.9.0.alpha.inline1 lib/playbook/markdown/template_handler.rb
playbook_ui-9.9.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.8.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.7.0.pre.alphawidth1 lib/playbook/markdown/template_handler.rb
playbook_ui-9.7.0.pre.alpha.a11y.btn lib/playbook/markdown/template_handler.rb
playbook_ui-9.7.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.6.1 lib/playbook/markdown/template_handler.rb
playbook_ui-9.6.1.pre.deps1 lib/playbook/markdown/template_handler.rb
playbook_ui-9.6.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.5.0.alpha.rs.downgrade lib/playbook/markdown/template_handler.rb
playbook_ui-9.5.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.4.0.alpha.sisense lib/playbook/markdown/template_handler.rb
playbook_ui-9.4.0.alpha.user.kit.bug lib/playbook/markdown/template_handler.rb
playbook_ui-9.4.0 lib/playbook/markdown/template_handler.rb
playbook_ui-9.3.1.pre.alpha2 lib/playbook/markdown/template_handler.rb
playbook_ui-9.4.0.pre.alpha2 lib/playbook/markdown/template_handler.rb
playbook_ui-9.4.0.pre.alpha1 lib/playbook/markdown/template_handler.rb
playbook_ui-9.3.1.pre.alpha1 lib/playbook/markdown/template_handler.rb