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
98
99
100
|
# File 'lib/rouge/theme.rb', line 98
def base_style
styles[Token::Tokens::Text]
end
|
.find(n) ⇒ Object
109
110
111
|
# File 'lib/rouge/theme.rb', line 109
def find(n)
registry[n.to_s]
end
|
.get_own_style(token) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/rouge/theme.rb', line 86
def get_own_style(token)
token.token_chain.each do |anc|
return styles[anc] if styles[anc]
end
nil
end
|
.get_style(token) ⇒ Object
94
95
96
|
# File 'lib/rouge/theme.rb', line 94
def get_style(token)
get_own_style(token) || base_style
end
|
.name(n = nil) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/rouge/theme.rb', line 102
def name(n=nil)
return @name if n.nil?
@name = n.to_s
Theme.registry[@name] = self
end
|
.palette(arg = {}) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# 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
|
.registry ⇒ Object
113
114
115
|
# File 'lib/rouge/theme.rb', line 113
def registry
@registry ||= {}
end
|
.render(opts = {}, &b) ⇒ Object
71
72
73
|
# File 'lib/rouge/theme.rb', line 71
def self.render(opts={}, &b)
new(opts).render(&b)
end
|
.style(*tokens) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/rouge/theme.rb', line 76
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
67
68
69
|
# File 'lib/rouge/theme.rb', line 67
def self.styles
@styles ||= InheritableHash.new(superclass.styles)
end
|
Instance Method Details
#styles ⇒ Object
45
46
47
|
# File 'lib/rouge/theme.rb', line 45
def styles
@styles ||= self.class.styles.dup
end
|