Class: Rouge::Theme
Defined Under Namespace
Classes: Style
Constant Summary
Rouge::Token::Tokens::Num, Rouge::Token::Tokens::Str
Class Method Summary
collapse
Instance Method Summary
collapse
token
Class Method Details
.find(n) ⇒ Object
103
104
105
|
# File 'lib/rouge/theme.rb', line 103
def find(n)
registry[n.to_s]
end
|
.get_own_style(token) ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/rouge/theme.rb', line 84
def get_own_style(token)
token.token_chain.each do |anc|
return styles[anc] if styles[anc]
end
nil
end
|
.get_style(token) ⇒ Object
92
93
94
|
# File 'lib/rouge/theme.rb', line 92
def get_style(token)
get_own_style(token) || styles[Token::Tokens::Text]
end
|
.name(n = nil) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/rouge/theme.rb', line 96
def name(n=nil)
return @name if n.nil?
@name = n.to_s
Theme.registry[@name] = self
end
|
.palette(arg = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/rouge/theme.rb', line 48
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
107
108
109
|
# File 'lib/rouge/theme.rb', line 107
def registry
@registry ||= {}
end
|
.render(opts = {}, &b) ⇒ Object
69
70
71
|
# File 'lib/rouge/theme.rb', line 69
def self.render(opts={}, &b)
new(opts).render(&b)
end
|
.style(*tokens) ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/rouge/theme.rb', line 74
def style(*tokens)
style = tokens.last.is_a?(Hash) ? tokens.pop : {}
style = Style.new(self, style)
tokens.each do |tok|
styles[tok] = style
end
end
|
.styles ⇒ Object
65
66
67
|
# File 'lib/rouge/theme.rb', line 65
def self.styles
@styles ||= InheritableHash.new(superclass.styles)
end
|
Instance Method Details
#styles ⇒ Object
43
44
45
|
# File 'lib/rouge/theme.rb', line 43
def styles
@styles ||= self.class.styles.dup
end
|