class Redcarpet::Render::Safe
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.
Public Class Methods
new(extensions = {})
click to toggle source
Calls superclass method
Redcarpet::Render::HTML::new
# File lib/redcarpet.rb, line 32 def initialize(extensions = {}) super({ escape_html: true, safe_links_only: true }.merge(extensions)) end
Public Instance Methods
block_code(code, lang)
click to toggle source
# File lib/redcarpet.rb, line 39 def block_code(code, lang) "<pre>" \ "<code>#{html_escape(code)}</code>" \ "</pre>" end
Private Instance Methods
html_escape(string)
click to toggle source
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