| Class | CodeRay::Encoders::HTML::CSS |
| In: |
lib/coderay/encoders/html/css.rb
|
| Parent: | Object |
| CSS_CLASS_PATTERN | = | / ( # $1 = selectors (?: (?: \s* \. [-\w]+ )+ \s* ,? )+ ) \s* \{ \s* ( [^\}]+ )? # $2 = style \s* \} \s* | ( . ) # $3 = error /mx |
| stylesheet | [R] |
# File lib/coderay/encoders/html/css.rb, line 9
9: def CSS.load_stylesheet style = nil
10: CodeRay::Styles[style]
11: end
# File lib/coderay/encoders/html/css.rb, line 13
13: def initialize style = :default
14: @classes = Hash.new
15: style = CSS.load_stylesheet style
16: @stylesheet = [
17: style::CSS_MAIN_STYLES,
18: style::TOKEN_COLORS.gsub(/^(?!$)/, '.CodeRay ')
19: ].join("\n")
20: parse style::TOKEN_COLORS
21: end
# File lib/coderay/encoders/html/css.rb, line 23
23: def [] *styles
24: cl = @classes[styles.first]
25: return '' unless cl
26: style = ''
27: 1.upto(styles.size) do |offset|
28: break if style = cl[styles[offset .. -1]]
29: end
30: # warn 'Style not found: %p' % [styles] if style.empty?
31: return style
32: end