Class: Lines::ApplicationHelper::HTMLwithPygments
- Inherits:
-
Redcarpet::Render::XHTML
- Object
- Redcarpet::Render::XHTML
- Lines::ApplicationHelper::HTMLwithPygments
- 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
20 21 22 23 24 25 |
# File 'app/helpers/lines/application_helper.rb', line 20 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 |