Class: Downr::Render

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Includes:
Redcarpet::Render::SmartyPants
Defined in:
lib/downr/render.rb

Overview

This class wraps both pygmentize and RailsEmoji gems to create a custom renderer

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ Render

Initializes the Render object

Parameters:

  • opts (Hash)

    a customizable set of options



16
17
18
19
20
# File 'lib/downr/render.rb', line 16

def initialize(opt)
  opt = clean_options(opt)
  @options = opt
  super
end

Instance Method Details

#block_code(code, language) ⇒ String

Hook for Redcarpet render

Parameters:

  • code (String)

    the code snippet to parse

  • language (String)

    the coding language

Returns:

  • (String)

    html



31
32
33
34
35
36
37
# File 'lib/downr/render.rb', line 31

def block_code(code, language)
  if(@options[:pygmentize])
    return pygmentize(code, language)
  end

  code
end

#preprocess(full_document) ⇒ String

Hook for Redcarpet render

Parameters:

  • full_document (String)

    the complete doc

Returns:

  • (String)

    html



46
47
48
49
50
51
52
# File 'lib/downr/render.rb', line 46

def preprocess(full_document)
  if(@options[:emojify])
    return emojify(full_document)
  end

  super full_document
end