class Rouge::Theme
Public Class Methods
Source
# File lib/rouge/theme.rb, line 110 def base_style get_own_style(Token::Tokens::Text) end
Source
# File lib/rouge/theme.rb, line 98 def get_own_style(token) token.token_chain.reverse_each do |anc| return Style.new(self, styles[anc]) if styles[anc] end nil end
Source
# File lib/rouge/theme.rb, line 106 def get_style(token) get_own_style(token) || base_style end
Source
# File lib/rouge/theme.rb, line 114 def name(n=nil) return @name if n.nil? @name = n.to_s register(@name) end
Source
# File lib/rouge/theme.rb, line 50 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
Source
# File lib/rouge/theme.rb, line 121 def register(name) Theme.registry[name.to_s] = self end
Source
# File lib/rouge/theme.rb, line 73 def self.render(opts={}, &b) new(opts).render(&b) end
Source
# File lib/rouge/theme.rb, line 90 def style(*tokens) style = tokens.last.is_a?(Hash) ? tokens.pop : {} tokens.each do |tok| styles[tok] = style end end
Source
# File lib/rouge/theme.rb, line 69 def self.styles @styles ||= InheritableHash.new(superclass.styles) end
Public Instance Methods
Source
# File lib/rouge/theme.rb, line 77 def get_own_style(token) self.class.get_own_style(token) end
Source
# File lib/rouge/theme.rb, line 81 def get_style(token) self.class.get_style(token) end
Source
# File lib/rouge/theme.rb, line 45 def styles @styles ||= self.class.styles.dup end