/usr/lib/ruby/vendor_ruby/redcarpet.rb is in ruby-redcarpet 3.3.4-2build1.
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 | require 'redcarpet.so'
require 'redcarpet/compat'
module Redcarpet
VERSION = '3.3.4'
class Markdown
attr_reader :renderer
end
module Render
# XHTML Renderer
class XHTML < HTML
def initialize(extensions = {})
super(extensions.merge(xhtml: true))
end
end
# HTML + SmartyPants renderer
class SmartyHTML < HTML
include SmartyPants
end
# A renderer object you can use to deal with users' input. It
# enables +escape_html+ and +safe_links_only+ by default.
#
# The +block_code+ callback is also overriden not to include
# the lang's class as the user can basically specify anything
# with the vanilla one.
class Safe < HTML
def initialize(extensions = {})
super({
escape_html: true,
safe_links_only: true
}.merge(extensions))
end
def block_code(code, lang)
"<pre>" \
"<code>#{html_escape(code)}</code>" \
"</pre>"
end
private
# TODO: This is far from ideal to have such method as we
# are duplicating existing code from Houdini. This method
# should be defined at the C level.
def html_escape(string)
string.gsub(/['&\"<>\/]/, {
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
"'" => ''',
"/" => '/',
})
end
end
# SmartyPants Mixin module
#
# Implements SmartyPants.postprocess, which
# performs smartypants replacements on the HTML file,
# once it has been fully rendered.
#
# To add SmartyPants postprocessing to your custom
# renderers, just mixin the module `include SmartyPants`
#
# You can also use this as a standalone SmartyPants
# implementation.
#
# Example:
#
# # Mixin
# class CoolRenderer < HTML
# include SmartyPants
# # more code here
# end
#
# # Standalone
# Redcarpet::Render::SmartyPants.render("you're")
#
module SmartyPants
extend self
def self.render(text)
postprocess text
end
end
end
end
|