class Rouge::Theme

def self.palette(arg={})

def self.palette(arg={})
  @palette ||= InheritableHash.new(superclass.palette)
  if arg.is_a? Hash
    @palette.merge! arg
    @palette
  else
    case arg
    when /#[0-9a-f]+/i
      arg
    else
      @palette[arg] or raise "not in palette: #{arg.inspect}"
    end
  end
end

def self.render(opts={}, &b)

def self.render(opts={}, &b)
  new(opts).render(&b)
end

def self.styles

def self.styles
  @styles ||= InheritableHash.new(superclass.styles)
end

def base_style

def base_style
  get_own_style(Token::Tokens::Text)
end

def find(n)

def find(n)
  registry[n.to_s]
end

def get_own_style(token)

def get_own_style(token)
  self.class.get_own_style(token)
end

def get_own_style(token)

def get_own_style(token)
  token.token_chain.reverse_each do |anc|
    return Style.new(self, styles[anc]) if styles[anc]
  end
  nil
end

def get_style(token)

def get_style(token)
  self.class.get_style(token)
end

def get_style(token)

def get_style(token)
  get_own_style(token) || base_style
end

def name

def name
  self.class.name
end

def name(n=nil)

def name(n=nil)
  return @name if n.nil?
  @name = n.to_s
  register(@name)
end

def palette(*a) self.class.palette(*a) end

def palette(*a) self.class.palette(*a) end

def register(name)

def register(name)
  Theme.registry[name.to_s] = self
end

def registry

def registry
  @registry ||= {}
end

def style(*tokens)

def style(*tokens)
  style = tokens.last.is_a?(Hash) ? tokens.pop : {}
  tokens.each do |tok|
    styles[tok] = style
  end
end

def styles

def styles
  @styles ||= self.class.styles.dup
end