@@ -3,21 +3,22 @@ module Encoders
3
3
4
4
class HTML
5
5
class CSS # :nodoc:
6
- def initialize style = :default
7
- @style = style
6
+ def initialize style_name = :default
7
+ @style_name = style_name
8
8
end
9
-
10
- def stylesheet
11
- @stylesheet ||= CodeRay ::Styles [ @style ]
9
+
10
+ def style
11
+ @style ||= CodeRay ::Styles [ @style_name ]
12
12
end
13
-
13
+
14
14
def css
15
- [
16
- stylesheet ::CSS_MAIN_STYLES ,
17
- stylesheet ::TOKEN_COLORS . gsub ( /^(?!$)/ , '.CodeRay ' )
15
+ @css ||= [
16
+ style ::CSS_MAIN_STYLES ,
17
+ style ::TOKEN_COLORS . gsub ( /^(?!$)/ , '.CodeRay ' )
18
18
] . join ( "\n " )
19
19
end
20
-
20
+ alias stylesheet css
21
+
21
22
def get_style_for_css_classes css_classes
22
23
cl = styles [ css_classes . first ]
23
24
return '' unless cl
@@ -29,7 +30,7 @@ def get_style_for_css_classes css_classes
29
30
return style
30
31
end
31
32
32
- private
33
+ private
33
34
34
35
CSS_CLASS_PATTERN = /
35
36
( # $1 = selectors
@@ -46,7 +47,7 @@ def get_style_for_css_classes css_classes
46
47
/mx
47
48
def styles
48
49
@styles ||= Hash . new . tap do |styles |
49
- stylesheet ::TOKEN_COLORS . scan CSS_CLASS_PATTERN do |selectors , style , error |
50
+ style ::TOKEN_COLORS . scan CSS_CLASS_PATTERN do |selectors , style , error |
50
51
raise "CSS parse error: '#{ error . inspect } ' not recognized" if error
51
52
for selector in selectors . split ( ',' )
52
53
classes = selector . scan ( /[-\w ]+/ )
0 commit comments