Class: Rouge::Theme
- Inherits:
-
Object
show all
- Defined in:
- lib/rouge/theme.rb
Defined Under Namespace
Classes: InheritableHash, Style
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find(n) ⇒ Object
128
129
130
|
# File 'lib/rouge/theme.rb', line 128
def find(n)
registry[n.to_s]
end
|
.get_style(token) ⇒ Object
113
114
115
116
117
118
119
|
# File 'lib/rouge/theme.rb', line 113
def get_style(token)
token.ancestors do |anc|
return styles[anc.name] if styles[anc.name]
end
styles['Text']
end
|
.name(n = nil) ⇒ Object
121
122
123
124
125
126
|
# File 'lib/rouge/theme.rb', line 121
def name(n=nil)
return @name if n.nil?
@name = n.to_s
Theme.registry[@name] = self
end
|
.palette(arg = {}) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/rouge/theme.rb', line 77
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
|
.registry ⇒ Object
132
133
134
|
# File 'lib/rouge/theme.rb', line 132
def registry
@registry ||= {}
end
|
.render(opts = {}, &b) ⇒ Object
98
99
100
|
# File 'lib/rouge/theme.rb', line 98
def self.render(opts={}, &b)
new(opts).render(&b)
end
|
.style(*tokens) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/rouge/theme.rb', line 103
def style(*tokens)
style = tokens.last.is_a?(Hash) ? tokens.pop : {}
style = Style.new(self, style)
tokens.each do |tok|
styles[tok.to_s] = style
end
end
|
.styles ⇒ Object
94
95
96
|
# File 'lib/rouge/theme.rb', line 94
def self.styles
@styles ||= InheritableHash.new(superclass.styles)
end
|
Instance Method Details
#styles ⇒ Object
72
73
74
|
# File 'lib/rouge/theme.rb', line 72
def styles
@styles ||= self.class.styles.dup
end
|