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
.base_style ⇒ Object
111
112
113
|
# File 'lib/rouge/theme.rb', line 111
def base_style
get_own_style(Token::Tokens::Text)
end
|
.find(n) ⇒ Object
126
127
128
|
# File 'lib/rouge/theme.rb', line 126
def find(n)
registry[n.to_s]
end
|
.get_own_style(token) ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/rouge/theme.rb', line 99
def get_own_style(token)
token.token_chain.reverse_each do |anc|
return Style.new(self, styles[anc]) if styles[anc]
end
nil
end
|
.get_style(token) ⇒ Object
107
108
109
|
# File 'lib/rouge/theme.rb', line 107
def get_style(token)
get_own_style(token) || base_style
end
|
.name(n = nil) ⇒ Object
115
116
117
118
119
120
|
# File 'lib/rouge/theme.rb', line 115
def name(n=nil)
return @name if n.nil?
@name = n.to_s
register(@name)
end
|
.palette(arg = {}) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/rouge/theme.rb', line 51
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
|
.register(name) ⇒ Object
122
123
124
|
# File 'lib/rouge/theme.rb', line 122
def register(name)
Theme.registry[name.to_s] = self
end
|
.registry ⇒ Object
130
131
132
|
# File 'lib/rouge/theme.rb', line 130
def registry
@registry ||= {}
end
|
.render(opts = {}, &b) ⇒ Object
74
75
76
|
# File 'lib/rouge/theme.rb', line 74
def self.render(opts={}, &b)
new(opts).render(&b)
end
|
.style(*tokens) ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/rouge/theme.rb', line 91
def style(*tokens)
style = tokens.last.is_a?(Hash) ? tokens.pop : {}
tokens.each do |tok|
styles[tok] = style
end
end
|
.styles ⇒ Object
70
71
72
|
# File 'lib/rouge/theme.rb', line 70
def self.styles
@styles ||= InheritableHash.new(superclass.styles)
end
|
Instance Method Details
#get_own_style(token) ⇒ Object
78
79
80
|
# File 'lib/rouge/theme.rb', line 78
def get_own_style(token)
self.class.get_own_style(token)
end
|
#get_style(token) ⇒ Object
82
83
84
|
# File 'lib/rouge/theme.rb', line 82
def get_style(token)
self.class.get_style(token)
end
|
#name ⇒ Object
86
87
88
|
# File 'lib/rouge/theme.rb', line 86
def name
self.class.name
end
|
#palette(*a) ⇒ Object
67
|
# File 'lib/rouge/theme.rb', line 67
def palette(*a) self.class.palette(*a) end
|
#styles ⇒ Object
46
47
48
|
# File 'lib/rouge/theme.rb', line 46
def styles
@styles ||= self.class.styles.dup
end
|