class Prawn::ManualBuilder::PrawnEncoder
Registers a to_prawn method on CodeRay. It returns an array of hashes to be used with formatted_text.
Usage:
CodeRay.scan(string, :ruby).to_prawn
Constants
- COLORS
Public Instance Methods
begin_group(kind)
click to toggle source
# File lib/prawn/manual_builder/syntax_highlight.rb, line 47 def begin_group(kind) @open << kind end
end_group(kind)
click to toggle source
# File lib/prawn/manual_builder/syntax_highlight.rb, line 51 def end_group(kind) @open.pop end
setup(options)
click to toggle source
Calls superclass method
# File lib/prawn/manual_builder/syntax_highlight.rb, line 35 def setup(options) super @out = [] @open = [] end
text_token(text, kind)
click to toggle source
# File lib/prawn/manual_builder/syntax_highlight.rb, line 41 def text_token(text, kind) color = COLORS[kind] || COLORS[@open.last] || COLORS[:default] @out << {:text => text, :color => color} end