Class: Rouge::CSSTheme

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

Instance Method Summary collapse

Methods inherited from Theme

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

Constructor Details

#initialize(opts = {}) ⇒ CSSTheme

Returns a new instance of CSSTheme.


131
132
133
# File 'lib/rouge/theme.rb', line 131

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

Instance Method Details

#render {|"#{@scope} table { border-spacing: 0; }"| ... } ⇒ Object

Yields:

  • ("#{@scope} table { border-spacing: 0; }")

135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/rouge/theme.rb', line 135

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

  # shared styles for tableized line numbers
  yield "#{@scope} table { border-spacing: 0; }"
  yield "#{@scope} table td { padding: 5px; }"
  yield "#{@scope} table .gutter { text-align: right; }"

  styles.each do |tokname, style|
    style.render(css_selector(Token[tokname]), &b)
  end
end

#style_for(tok) ⇒ Object


148
149
150
151
152
# File 'lib/rouge/theme.rb', line 148

def style_for(tok)
  styles.fetch(tok.name) do
    tok.parent ? style_for(tok.parent) : Style.new(self)
  end
end