Class: Rouge::Formatters::HTMLPygments

Inherits:
Rouge::Formatter show all
Defined in:
lib/rouge/formatters/html_pygments.rb

Constant Summary

Constants inherited from Rouge::Formatter

Rouge::Formatter::REGISTRY

Instance Method Summary collapse

Methods inherited from Rouge::Formatter

disable_escape!, enable_escape!, #escape?, escape_enabled?, #filter_escapes, find, format, #format, #render, tag, with_escape

Constructor Details

#initialize(inner, css_class = 'codehilite') ⇒ HTMLPygments

Returns a new instance of HTMLPygments.



11
12
13
14
# File 'lib/rouge/formatters/html_pygments.rb', line 11

def initialize(inner, css_class='codehilite')
  @inner = HTML.assert_html_formatter!(inner)
  @css_class = css_class
end

Instance Method Details

#stream(tokens) {|%(<div class="highlight"><pre class="#{@css_class}"><code>)| ... } ⇒ Object

Yields:

  • (%(<div class="highlight"><pre class="#{@css_class}"><code>))


16
17
18
19
20
# File 'lib/rouge/formatters/html_pygments.rb', line 16

def stream(tokens, &b)
  yield %(<div class="highlight"><pre class="#{@css_class}"><code>)
  @inner.stream(tokens, &b)
  yield "</code></pre></div>"
end