Class: Jekyll::HighlightBlock
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::HighlightBlock
- Includes:
- Liquid::StandardFilters
- Defined in:
- lib/jekyll/tags/highlight.rb
Instance Method Summary collapse
-
#initialize(tag_name, lang, tokens) ⇒ HighlightBlock
constructor
A new instance of HighlightBlock.
- #render(context) ⇒ Object
- #render_codehighlighter(context, code) ⇒ Object
- #render_pygments(context, code) ⇒ Object
Constructor Details
#initialize(tag_name, lang, tokens) ⇒ HighlightBlock
Returns a new instance of HighlightBlock.
6 7 8 9 |
# File 'lib/jekyll/tags/highlight.rb', line 6 def initialize(tag_name, lang, tokens) super @lang = lang.strip end |
Instance Method Details
#render(context) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/jekyll/tags/highlight.rb', line 11 def render(context) if Jekyll.pygments render_pygments(context, super.to_s) else render_codehighlighter(context, super.to_s) end end |
#render_codehighlighter(context, code) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jekyll/tags/highlight.rb', line 23 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 |