Skip to content

Commit b159057

Browse files
committed
tweak CSS tag/id token kind patch from noprompt
1 parent e23f69f commit b159057

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Changes.textile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ h2. Changes in 1.1
1515
* @CodeRay::TokenKinds@ should not be frozen [#130, thanks to Gavin Kistner]
1616
* Override Bootstrap's pre word-break setting for line numbers [#102, thanks to lightswitch05]
1717
* Accept keywords as Ruby 1.9 hash keys [#126]
18+
* New token type @:id@ for CSS/Sass [#27]
19+
* CSS scanner uses @:id@ and @:tag@ now [#27]
1820

1921
h2. Changes in 1.0.9
2022

lib/coderay/scanners/css.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CSS < Scanner
1010
:class, :pseudo_class, :tag,
1111
:id, :directive,
1212
:key, :value, :operator, :color, :float, :string,
13-
:error, :important,
13+
:error, :important, :type,
1414
] # :nodoc:
1515

1616
module RE # :nodoc:
@@ -99,7 +99,7 @@ def scan_tokens encoder, options
9999

100100
when :media_before_name
101101
if match = scan(RE::Ident)
102-
encoder.text_token match, :tag
102+
encoder.text_token match, :type
103103
states[-1] = :media_after_name
104104
next
105105
end

lib/coderay/scanners/sass.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ def scan_tokens encoder, options
3838
elsif case states.last
3939
when :initial, :media, :sass_inline
4040
if match = scan(/(?>#{RE::Ident})(?!\()/ox)
41-
encoder.text_token match, value_expected ? :value : (check(/.*:/) ? :key : :type)
41+
encoder.text_token match, value_expected ? :value : (check(/.*:/) ? :key : :tag)
4242
next
4343
elsif !value_expected && (match = scan(/\*/))
44-
encoder.text_token match, :type
44+
encoder.text_token match, :tag
4545
next
4646
elsif match = scan(RE::Class)
4747
encoder.text_token match, :class
4848
next
4949
elsif match = scan(RE::Id)
50-
encoder.text_token match, :constant
50+
encoder.text_token match, :id
5151
next
5252
elsif match = scan(RE::PseudoClass)
5353
encoder.text_token match, :pseudo_class

lib/coderay/styles/alpha.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Alpha < Style
8484
.function .delimiter { color:#024; font-weight:bold }
8585
.global-variable { color:#d70 }
8686
.hex { color:#02b }
87+
.id { color:#33D; font-weight:bold }
8788
.imaginary { color:#f00 }
8889
.include { color:#B44; font-weight:bold }
8990
.inline { background-color: hsla(0,0%,0%,0.07); color: black }

0 commit comments

Comments
 (0)