/usr/lib/ruby/vendor_ruby/tilt/markdown.rb is in ruby-tilt 2.0.0+really1.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | require 'tilt/template'
module Tilt
# Discount Markdown implementation. See:
# http://github.com/rtomayko/rdiscount
#
# RDiscount is a simple text filter. It does not support +scope+ or
# +locals+. The +:smart+ and +:filter_html+ options may be set true
# to enable those flags on the underlying RDiscount object.
class RDiscountTemplate < Template
self.default_mime_type = 'text/html'
ALIAS = {
:escape_html => :filter_html,
:smartypants => :smart
}
FLAGS = [:smart, :filter_html, :smartypants, :escape_html]
def flags
FLAGS.select { |flag| options[flag] }.map { |flag| ALIAS[flag] || flag }
end
def self.engine_initialized?
defined? ::RDiscount
end
def initialize_engine
require_template_library 'rdiscount'
end
def prepare
@engine = RDiscount.new(data, *flags)
@output = nil
end
def evaluate(scope, locals, &block)
@output ||= @engine.to_html
end
def allows_script?
false
end
end
# Upskirt Markdown implementation. See:
# https://github.com/tanoku/redcarpet
#
# Supports both Redcarpet 1.x and 2.x
class RedcarpetTemplate < Template
def self.engine_initialized?
defined? ::Redcarpet
end
def initialize_engine
require_template_library 'redcarpet'
end
def prepare
klass = [Redcarpet2, Redcarpet1].detect { |e| e.engine_initialized? }
@engine = klass.new(file, line, options) { data }
end
def evaluate(scope, locals, &block)
@engine.evaluate(scope, locals, &block)
end
def allows_script?
false
end
# Compatibility mode for Redcarpet 1.x
class Redcarpet1 < RDiscountTemplate
self.default_mime_type = 'text/html'
def self.engine_initialized?
defined? ::RedcarpetCompat
end
def prepare
@engine = RedcarpetCompat.new(data, *flags)
@output = nil
end
end
# Future proof mode for Redcarpet 2.x (not yet released)
class Redcarpet2 < Template
self.default_mime_type = 'text/html'
def self.engine_initialized?
defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown
end
def generate_renderer
renderer = options.delete(:renderer) || ::Redcarpet::Render::HTML
return renderer unless options.delete(:smartypants)
return renderer if renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants
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
def prepare
# try to support the same aliases
RDiscountTemplate::ALIAS.each do |opt, aka|
next if options.key? opt or not options.key? aka
options[opt] = options.delete(aka)
end
# only raise an exception if someone is trying to enable :escape_html
options.delete(:escape_html) unless options[:escape_html]
@engine = ::Redcarpet::Markdown.new(generate_renderer, options)
@output = nil
end
def evaluate(scope, locals, &block)
@output ||= @engine.render(data)
end
def allows_script?
false
end
end
end
# BlueCloth Markdown implementation. See:
# http://deveiate.org/projects/BlueCloth/
class BlueClothTemplate < Template
self.default_mime_type = 'text/html'
def self.engine_initialized?
defined? ::BlueCloth
end
def initialize_engine
require_template_library 'bluecloth'
end
def prepare
@engine = BlueCloth.new(data, options)
@output = nil
end
def evaluate(scope, locals, &block)
@output ||= @engine.to_html
end
def allows_script?
false
end
end
# Maruku markdown implementation. See:
# http://maruku.rubyforge.org/
class MarukuTemplate < Template
def self.engine_initialized?
defined? ::Maruku
end
def initialize_engine
require_template_library 'maruku'
end
def prepare
@engine = Maruku.new(data, options)
@output = nil
end
def evaluate(scope, locals, &block)
@output ||= @engine.to_html
end
def allows_script?
false
end
end
# Kramdown Markdown implementation. See:
# http://kramdown.rubyforge.org/
class KramdownTemplate < Template
DUMB_QUOTES = [39, 39, 34, 34]
def self.engine_initialized?
defined? ::Kramdown
end
def initialize_engine
require_template_library 'kramdown'
end
def prepare
options[:smart_quotes] = DUMB_QUOTES unless options[:smartypants]
@engine = Kramdown::Document.new(data, options)
@output = nil
end
def evaluate(scope, locals, &block)
@output ||= @engine.to_html
end
def allows_script?
false
end
end
end
|