Sha256: eca3202f9b5565af0c659537a758c484dc19b95fea6e39c8522d4b8d46393a32
Contents?: true
Size: 666 Bytes
Versions: 7
Compression:
Stored size: 666 Bytes
Contents
require 'redcarpet' module MarkdownHelper class HTMLWithPygments < Redcarpet::Render::HTML 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 end def markdown(text) renderer = HTMLWithPygments.new(hard_wrap: true, filter_html: true) options = { autolink: true, no_intra_emphasis: true, fenced_code_blocks: true, lax_html_blocks: true, strikethrough: true, superscript: true } Redcarpet::Markdown.new(renderer, options).render(text).html_safe end end
Version data entries
7 entries across 7 versions & 1 rubygems