Class: Redcarpet::Render::Safe

Inherits:
HTML
  • Object
show all
Defined in:
lib/redcarpet.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initialize(extensions = {}) ⇒ Safe

Returns a new instance of Safe.



32
33
34
35
36
37
# File 'lib/redcarpet.rb', line 32

def initialize(extensions = {})
  super({
    escape_html: true,
    safe_links_only: true
  }.merge(extensions))
end

Instance Method Details

#block_code(code, lang) ⇒ Object



39
40
41
42
43
# File 'lib/redcarpet.rb', line 39

def block_code(code, lang)
  "<pre>" \
    "<code>#{html_escape(code)}</code>" \
  "</pre>"
end