Object
# 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
# File lib/coderay/encoders/html/css.rb, line 49
49: def parse stylesheet
50: stylesheet.scan CSS_CLASS_PATTERN do |selectors, style, error|
51: raise "CSS parse error: '#{error.inspect}' not recognized" if error
52: for selector in selectors.split(',')
53: classes = selector.scan(/[-\w]+/)
54: cl = classes.pop
55: @classes[cl] ||= Hash.new
56: @classes[cl][classes] = style.to_s.strip.delete(' ').chomp(';')
57: end
58: end
59: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.