Sha256: cb943873bf64ed1f42c536e37ccef177654f3ab3053884faac6a29f1b3274e8e
Contents?: true
Size: 781 Bytes
Versions: 10
Compression:
Stored size: 781 Bytes
Contents
module Jekyll class HighlightBlock < Liquid::Block include Liquid::StandardFilters def initialize(tag_name, lang, tokens) super @lang = lang.strip end def render(context) if Jekyll.pygments render_pygments(context, super.to_s) else render_codehighlighter(context, super.to_s) end end def render_pygments(context, code) "<notextile>" + Albino.new(code, @lang).to_s + "</notextile>" end def render_codehighlighter(context, code) #The div is required because RDiscount blows ass <<-HTML <div> <pre> <code class='#{@lang}'>#{h(code).strip}</code> </pre> </div> HTML end end end Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
Version data entries
10 entries across 10 versions & 5 rubygems