From b9ce754961ea97dda8368f0a53d2113840b8f168 Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 14 Apr 2010 23:07:17 +0000 Subject: CSS Scanner: Adding support for CSS 3 functions and colors, changing highlighting of attrbiute selectors (closes #224). --- lib/coderay/scanners/css.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/coderay/scanners/css.rb') diff --git a/lib/coderay/scanners/css.rb b/lib/coderay/scanners/css.rb index 1806d24..75cd056 100644 --- a/lib/coderay/scanners/css.rb +++ b/lib/coderay/scanners/css.rb @@ -41,7 +41,7 @@ module Scanners Dimension = /#{Num}#{Unit}/ Comment = %r! /\* (?: .*? \*/ | .* ) !mx - Function = /(?:url|alpha)\((?:[^)\n\r\f]|\\\))*\)?/ + Function = /(?:url|alpha|attr|counters?)\((?:[^)\n\r\f]|\\\))*\)?/ Id = /##{Name}/ Class = /\.#{Name}/ @@ -76,11 +76,9 @@ module Scanners kind = :pseudo_class elsif match = scan(RE::AttributeSelector) # TODO: Improve highlighting inside of attribute selectors. - tokens << [:open, :string] - tokens << [match[0,1], :delimiter] - tokens << [match[1..-2], :content] if match.size > 2 - tokens << [match[-1,1], :delimiter] if match[-1] == ?] - tokens << [:close, :string] + tokens << [match[0,1], :operator] + tokens << [match[1..-2], :attribute_name] if match.size > 2 + tokens << [match[-1,1], :operator] if match[-1] == ?] next elsif match = scan(/@media/) kind = :directive @@ -171,7 +169,7 @@ module Scanners elsif scan(/! *important/) kind = :important - elsif scan(/rgb\([^()\n]*\)?/) + elsif scan(/(?:rgb|hsl)a?\([^()\n]*\)?/) kind = :color elsif scan(/#{RE::AtKeyword}/o) -- cgit v1.2.1