diff options
author | murphy <murphy@rubychan.de> | 2008-09-16 22:07:44 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2008-09-16 22:07:44 +0000 |
commit | e46b6cbe74db250d743e7f194bfc7514529a82cc (patch) | |
tree | 851e2669d010cddffcad61189055282360cab2fc /lib/coderay/encoders/html | |
parent | e7b3056418e54db4361b053a7af030d83e15acf8 (diff) | |
download | coderay-e46b6cbe74db250d743e7f194bfc7514529a82cc.tar.gz |
New: *JavaScript Scanner* (closes #23).
* It's quite good and fast, but still a beta.
* I included Prototype and script.aculo.us as example code for testing.
More changes:
* Added two new token classes, :keyword and :key, along with CSS styles.
** Actually, we should use :keyword for most scanners that now use :reserved.
* HTML Encoder: The CSS parser understands multiple selectors separated by commas.
Diffstat (limited to 'lib/coderay/encoders/html')
-rw-r--r-- | lib/coderay/encoders/html/css.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/coderay/encoders/html/css.rb b/lib/coderay/encoders/html/css.rb index d577602..90d8cb1 100644 --- a/lib/coderay/encoders/html/css.rb +++ b/lib/coderay/encoders/html/css.rb @@ -34,9 +34,12 @@ module Encoders private CSS_CLASS_PATTERN = / - ( (?: # $1 = classes - \s* \. [-\w]+ - )+ ) + ( # $1 = selectors + (?: + (?: \s* \. [-\w]+ )+ + \s* ,? + )+ + ) \s* \{ \s* ( [^\}]+ )? # $2 = style \s* \} \s* @@ -44,12 +47,14 @@ module Encoders ( . ) # $3 = error /mx def parse stylesheet - stylesheet.scan CSS_CLASS_PATTERN do |classes, style, error| + stylesheet.scan CSS_CLASS_PATTERN do |selectors, style, error| raise "CSS parse error: '#{error.inspect}' not recognized" if error - styles = classes.scan(/[-\w]+/) - cl = styles.pop - @classes[cl] ||= Hash.new - @classes[cl][styles] = style.to_s.strip + for selector in selectors.split(',') + classes = selector.scan(/[-\w]+/) + cl = classes.pop + @classes[cl] ||= Hash.new + @classes[cl][classes] = style.to_s.strip + end end end |