Sha256: c391b73b7e8fdeda0e5d8551674482f308ce8950a9abb23b7f7d82ec83c29966

Contents?: true

Size: 1.04 KB

Versions: 237

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

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

237 entries across 237 versions & 1 rubygems

Version Path
playbook_ui-12.17.1 lib/playbook/markdown/template_handler.rb
playbook_ui-12.17.0.pre.alpha.lightboxcurrentPhotoIndex582 lib/playbook/markdown/template_handler.rb
playbook_ui-12.17.0 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0.pre.alpha.tooltippositionprop566 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg558 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg547 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg532 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0.pre.alpha.lightboxcurrentphotoprop531 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0.pre.alpha.tiptaptestingpart1528 lib/playbook/markdown/template_handler.rb
playbook_ui-12.16.0 lib/playbook/markdown/template_handler.rb
playbook_ui-12.15.0 lib/playbook/markdown/template_handler.rb
playbook_ui-12.14.0.pre.alpha.lightboxcurrentphotoprop460 lib/playbook/markdown/template_handler.rb
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown457 lib/playbook/markdown/template_handler.rb
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown456 lib/playbook/markdown/template_handler.rb
playbook_ui-12.14.0 lib/playbook/markdown/template_handler.rb
playbook_ui-12.13.0.pre.alpha.PLAY693tooltipwrongbg440 lib/playbook/markdown/template_handler.rb
playbook_ui-12.13.0.pre.alpha.addingProductTokens439 lib/playbook/markdown/template_handler.rb
playbook_ui-12.13.0.pre.alpha.PLAY705phonenumberkit438 lib/playbook/markdown/template_handler.rb
playbook_ui-12.13.0 lib/playbook/markdown/template_handler.rb
playbook_ui-12.12.0.pre.alpha.PLAY697sandpacklayoutstyles413 lib/playbook/markdown/template_handler.rb