lib/rouge/formatters/terminal256.rb in rouge-2.1.1 vs lib/rouge/formatters/terminal256.rb in rouge-2.2.0
- old
+ new
@@ -2,16 +2,24 @@
module Rouge
module Formatters
# A formatter for 256-color terminals
class Terminal256 < Formatter
+ tag 'terminal256'
+
# @private
attr_reader :theme
- # @argument theme
+ # @param [Hash,Rouge::Theme] theme
# the theme to render with.
- def initialize(theme=nil)
- @theme = theme || Themes::ThankfulEyes
+ def initialize(theme = Themes::ThankfulEyes.new)
+ if theme.is_a?(Rouge::Theme)
+ @theme = theme
+ elsif theme.is_a?(Hash)
+ @theme = theme[:theme] || Themes::ThankfulEyes.new
+ else
+ raise ArgumentError, "invalid theme: #{theme.inspect}"
+ end
end
def stream(tokens, &b)
tokens.each do |tok, val|
escape = escape_sequence(tok)