Class: Rouge::CSSTheme

Inherits:
Theme
  • Object
show all
Defined in:
lib/rouge/theme.rb

Constant Summary

Constants included from Token::Tokens

Token::Tokens::Num, Token::Tokens::Str

Instance Method Summary collapse

Methods inherited from Theme

base_style, find, get_own_style, #get_own_style, get_style, #get_style, name, #palette, palette, register, registry, render, style, styles, #styles

Methods included from Token::Tokens

token

Constructor Details

#initialize(opts = {}) ⇒ CSSTheme

Returns a new instance of CSSTheme.


159
160
161
# File 'lib/rouge/theme.rb', line 159

def initialize(opts={})
  @scope = opts[:scope] || '.highlight'
end

Instance Method Details

#render {|"#{@scope} table td { padding: 5px; }"| ... } ⇒ Object

Yields:

  • ("#{@scope} table td { padding: 5px; }")

163
164
165
166
167
168
169
170
171
172
173
# File 'lib/rouge/theme.rb', line 163

def render(&b)
  return enum_for(:render).to_a.join("\n") unless b

  # shared styles for tableized line numbers
  yield "#{@scope} table td { padding: 5px; }"
  yield "#{@scope} table pre { margin: 0; }"

  styles.each do |tok, style|
    Style.new(self, style).render(css_selector(tok), &b)
  end
end

#render_base(selector, &b) ⇒ Object


175
176
177
# File 'lib/rouge/theme.rb', line 175

def render_base(selector, &b)
  self.class.base_style.render(selector, &b)
end

#style_for(tok) ⇒ Object


179
180
181
# File 'lib/rouge/theme.rb', line 179

def style_for(tok)
  self.class.get_style(tok)
end