Sha256: 30bd12f02b780658a3eb79193ed5f88d9ede01def290b8db7e661ae9c4204d19
Contents?: true
Size: 743 Bytes
Versions: 1
Compression:
Stored size: 743 Bytes
Contents
module Hitchens class ApplicationDecorator < Draper::Base def markdown(text) syntax_highlighter(markdown_parser.render(text)).html_safe end private def markdown_parser @@parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true, :fenced_code_blocks => true) end def syntax_highlighter(html) doc = Nokogiri::HTML(html) doc.search("code").each do |pre| code_ray = CodeRay.scan(pre.text.rstrip, pre[:class]).div # first line of code wasn't indented as much as others # need to add a line break after the pre tag pre.replace code_ray.sub('<pre>', "<pre>\n") end doc.to_s end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hitchens-0.0.1 | app/decorators/hitchens/application_decorator.rb |