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
73
# File 'lib/redmine/syntax_highlighting.rb', line 70

def initialize(formatter)
  super()
  @formatter = formatter
end

Instance Method Details

#stream(tokens) ⇒ Object



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

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