Class: Dispersion::Highlighter

Inherits:
Object
  • Object
show all
Defined in:
lib/dispersion/highlighter.rb

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Highlighter

Returns a new instance of Highlighter.



5
6
7
8
9
# File 'lib/dispersion/highlighter.rb', line 5

def initialize(code)
	@code = code
	@annotations = Dispersion::Annotator.call(code)
	freeze
end

Instance Method Details

#to_ansi(theme: nil) ⇒ Object



11
12
13
# File 'lib/dispersion/highlighter.rb', line 11

def to_ansi(theme: nil)
	Dispersion::Formatters::ANSI.new(@code, annotations: @annotations, theme:).call
end

#to_htmlObject



15
16
17
# File 'lib/dispersion/highlighter.rb', line 15

def to_html
	Dispersion::Formatters::HTML.new(@code, annotations: @annotations).call
end