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.
# File lib/redcarpet.rb, line 32 def initialize(extensions = {}) super({ escape_html: true, safe_links_only: true }.merge(extensions)) end
# File lib/redcarpet.rb, line 39 def block_code(code, lang) "<pre>" "<code>#{html_escape(code)}</code>" "</pre>" end
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.
# File lib/redcarpet.rb, line 50 def html_escape(string) string.gsub(/['&\"<>\/]/, { '&' => '&', '<' => '<', '>' => '>', '"' => '"', "'" => ''', "/" => '/', }) end