Class: Redmine::SyntaxHighlighting::Rouge::CustomHTMLLinewise

Inherits:
Rouge::Formatter
  • Object
show all
Defined in:
lib/redmine/syntax_highlighting.rb

Overview

Customized formatter based on Rouge::Formatters::HTMLLinewise Syntax highlighting is completed within each line.

Instance Method Summary collapse

Constructor Details

#initialize(formatter) ⇒ CustomHTMLLinewise

Returns a new instance of CustomHTMLLinewise.



70
71
72
# File 'lib/redmine/syntax_highlighting.rb', line 70

def initialize(formatter)
  @formatter = formatter
end

Instance Method Details

#stream(tokens, &b) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/redmine/syntax_highlighting.rb', line 74

def stream(tokens, &b)
  token_lines(tokens) do |line|
    line.each do |tok, val|
      yield @formatter.span(tok, val)
    end
    yield "\n"
  end
end