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

Since:

  • 4.0.0



61
62
63
# File 'lib/redmine/syntax_highlighting.rb', line 61

def initialize(formatter)
  @formatter = formatter
end

Instance Method Details

#stream(tokens, &b) ⇒ Object

Since:

  • 4.0.0



65
66
67
68
69
70
71
72
# File 'lib/redmine/syntax_highlighting.rb', line 65

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