Sha256: 3f562e082a7e8dfe757c2393369379dc3be44c083764665d00071c4b6b641e41

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true
require_relative 'template'
require 'redcarpet'

aliases = {:escape_html => :filter_html, :smartypants => :smart}.freeze

Tilt::RedcarpetTemplate = Tilt::StaticTemplate.subclass do
  aliases.each do |opt, aka|
    if options.key?(aka) || !@options.key?(opt)
      @options[opt] = @options.delete(aka)
    end
  end

  # only raise an exception if someone is trying to enable :escape_html
  @options.delete(:escape_html) unless @options[:escape_html]

  renderer = @options.delete(:renderer) || ::Redcarpet::Render::HTML.new(@options)
  if options.delete(:smartypants) && !(renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants)
    renderer = if renderer == ::Redcarpet::Render::XHTML
      ::Redcarpet::Render::SmartyHTML.new(:xhtml => true)
    elsif renderer == ::Redcarpet::Render::HTML
      ::Redcarpet::Render::SmartyHTML
    elsif renderer.is_a? Class
      Class.new(renderer) { include ::Redcarpet::Render::SmartyPants }
    else
      renderer.extend ::Redcarpet::Render::SmartyPants
    end
  end

  Redcarpet::Markdown.new(renderer, @options).render(@data)
end

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
brakeman-6.2.2 bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/redcarpet.rb
brakeman-6.2.2.rc1 bundle/ruby/3.3.0/gems/tilt-2.4.0/lib/tilt/redcarpet.rb
brakeman-6.2.1 bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/redcarpet.rb
brakeman-6.2.0 bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/redcarpet.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/tilt-2.4.0/lib/tilt/redcarpet.rb
tilt-2.4.0 lib/tilt/redcarpet.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/tilt-2.3.0/lib/tilt/redcarpet.rb
tilt-2.3.0 lib/tilt/redcarpet.rb