Class: Lines::ApplicationHelper::HTMLwithPygments

Inherits:
Redcarpet::Render::XHTML
  • Object
show all
Defined in:
app/helpers/lines/application_helper.rb

Overview

Highlights and formats code fragments with Pygments

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object



10
11
12
13
14
15
# File 'app/helpers/lines/application_helper.rb', line 10

def block_code(code, language)
  sha = Digest::SHA1.hexdigest(code)
  Rails.cache.fetch ["code", language, sha].join('-') do
    Pygments.highlight(code, lexer: language)
  end
end