Class: Rouge::Theme
- Inherits:
-
Object
- Object
- Rouge::Theme
- Defined in:
- lib/rouge/theme.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Style
Class Method Summary collapse
- .find(n) ⇒ Object
- .get_own_style(token) ⇒ Object
- .get_style(token) ⇒ Object
- .name(n = nil) ⇒ Object
- .palette(arg = {}) ⇒ Object
- .registry ⇒ Object
- .render(opts = {}, &b) ⇒ Object
- .style(*tokens) ⇒ Object
- .styles ⇒ Object
Instance Method Summary collapse
Class Method Details
.find(n) ⇒ Object
99 100 101 |
# File 'lib/rouge/theme.rb', line 99 def find(n) registry[n.to_s] end |
.get_own_style(token) ⇒ Object
82 83 84 85 86 |
# File 'lib/rouge/theme.rb', line 82 def get_own_style(token) token.ancestors do |anc| return styles[anc.name] if styles[anc.name] end end |
.get_style(token) ⇒ Object
88 89 90 |
# File 'lib/rouge/theme.rb', line 88 def get_style(token) get_own_style(token) || style['Text'] end |
.name(n = nil) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/rouge/theme.rb', line 92 def name(n=nil) return @name if n.nil? @name = n.to_s Theme.registry[@name] = self end |
.palette(arg = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rouge/theme.rb', line 46 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
103 104 105 |
# File 'lib/rouge/theme.rb', line 103 def registry @registry ||= {} end |
.render(opts = {}, &b) ⇒ Object
67 68 69 |
# File 'lib/rouge/theme.rb', line 67 def self.render(opts={}, &b) new(opts).render(&b) end |
.style(*tokens) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/rouge/theme.rb', line 72 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
63 64 65 |
# File 'lib/rouge/theme.rb', line 63 def self.styles @styles ||= InheritableHash.new(superclass.styles) end |
Instance Method Details
#styles ⇒ Object
41 42 43 |
# File 'lib/rouge/theme.rb', line 41 def styles @styles ||= self.class.styles.dup end |