rouge 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/Gemfile +2 -0
  2. data/bin/rougify +1 -1
  3. data/lib/rouge/demos/{text → plaintext} +0 -0
  4. data/lib/rouge/formatters/html.rb +13 -8
  5. data/lib/rouge/formatters/terminal256.rb +15 -11
  6. data/lib/rouge/lexer.rb +3 -1
  7. data/lib/rouge/lexers/c.rb +65 -55
  8. data/lib/rouge/lexers/clojure.rb +19 -19
  9. data/lib/rouge/lexers/coffeescript.rb +42 -42
  10. data/lib/rouge/lexers/common_lisp.rb +49 -48
  11. data/lib/rouge/lexers/conf.rb +6 -6
  12. data/lib/rouge/lexers/cpp.rb +48 -48
  13. data/lib/rouge/lexers/csharp.rb +25 -25
  14. data/lib/rouge/lexers/css.rb +32 -33
  15. data/lib/rouge/lexers/diff.rb +8 -8
  16. data/lib/rouge/lexers/elixir.rb +30 -30
  17. data/lib/rouge/lexers/erb.rb +5 -5
  18. data/lib/rouge/lexers/erlang.rb +38 -38
  19. data/lib/rouge/lexers/factor.rb +56 -56
  20. data/lib/rouge/lexers/gherkin.rb +27 -27
  21. data/lib/rouge/lexers/go.rb +21 -21
  22. data/lib/rouge/lexers/groovy.rb +32 -32
  23. data/lib/rouge/lexers/haml.rb +35 -35
  24. data/lib/rouge/lexers/handlebars.rb +27 -27
  25. data/lib/rouge/lexers/haskell.rb +78 -79
  26. data/lib/rouge/lexers/html.rb +28 -28
  27. data/lib/rouge/lexers/http.rb +13 -13
  28. data/lib/rouge/lexers/ini.rb +13 -13
  29. data/lib/rouge/lexers/io.rb +19 -19
  30. data/lib/rouge/lexers/java.rb +29 -29
  31. data/lib/rouge/lexers/javascript.rb +49 -52
  32. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  33. data/lib/rouge/lexers/llvm.rb +14 -14
  34. data/lib/rouge/lexers/lua.rb +33 -33
  35. data/lib/rouge/lexers/make.rb +26 -26
  36. data/lib/rouge/lexers/markdown.rb +49 -49
  37. data/lib/rouge/lexers/nginx.rb +19 -19
  38. data/lib/rouge/lexers/perl.rb +53 -54
  39. data/lib/rouge/lexers/php.rb +42 -43
  40. data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
  41. data/lib/rouge/lexers/prolog.rb +19 -19
  42. data/lib/rouge/lexers/puppet.rb +40 -40
  43. data/lib/rouge/lexers/python.rb +63 -63
  44. data/lib/rouge/lexers/r.rb +15 -15
  45. data/lib/rouge/lexers/racket.rb +29 -29
  46. data/lib/rouge/lexers/ruby.rb +94 -97
  47. data/lib/rouge/lexers/rust.rb +37 -37
  48. data/lib/rouge/lexers/sass.rb +15 -15
  49. data/lib/rouge/lexers/sass/common.rb +144 -136
  50. data/lib/rouge/lexers/scheme.rb +25 -25
  51. data/lib/rouge/lexers/scss.rb +7 -7
  52. data/lib/rouge/lexers/sed.rb +39 -39
  53. data/lib/rouge/lexers/shell.rb +45 -45
  54. data/lib/rouge/lexers/smalltalk.rb +36 -36
  55. data/lib/rouge/lexers/sql.rb +27 -27
  56. data/lib/rouge/lexers/tcl.rb +34 -34
  57. data/lib/rouge/lexers/tex.rb +24 -24
  58. data/lib/rouge/lexers/toml.rb +18 -18
  59. data/lib/rouge/lexers/viml.rb +19 -19
  60. data/lib/rouge/lexers/xml.rb +16 -16
  61. data/lib/rouge/lexers/yaml.rb +78 -81
  62. data/lib/rouge/plugins/redcarpet.rb +1 -1
  63. data/lib/rouge/regex_lexer.rb +31 -14
  64. data/lib/rouge/template_lexer.rb +1 -1
  65. data/lib/rouge/theme.rb +12 -10
  66. data/lib/rouge/themes/thankful_eyes.rb +43 -43
  67. data/lib/rouge/token.rb +145 -148
  68. data/lib/rouge/version.rb +1 -1
  69. metadata +4 -4
@@ -214,65 +214,65 @@ module Rouge
214
214
  symbol = /(\|[^\|]+\||#{nonmacro}#{constituent}*)/
215
215
 
216
216
  state :root do
217
- rule /\s+/m, 'Text'
218
- rule /;.*$/, 'Comment.Single'
219
- rule /#\|/, 'Comment.Multiline', :multiline_comment
217
+ rule /\s+/m, Text
218
+ rule /;.*$/, Comment::Single
219
+ rule /#\|/, Comment::Multiline, :multiline_comment
220
220
 
221
221
  # encoding comment
222
- rule /#\d*Y.*$/, 'Comment.Special'
223
- rule /"(\\.|[^"\\])*"/, 'Literal.String'
222
+ rule /#\d*Y.*$/, Comment::Special
223
+ rule /"(\\.|[^"\\])*"/, Str
224
224
 
225
- rule /[:']#{symbol}/, 'Literal.String.Symbol'
226
- rule /['`]/, 'Operator'
225
+ rule /[:']#{symbol}/, Str::Symbol
226
+ rule /['`]/, Operator
227
227
 
228
228
  # numbers
229
- rule /[-+]?\d+\.?#{terminated}/, 'Literal.Number.Integer'
230
- rule %r([-+]?\d+/\d+#{terminated}), 'Literal.Number.Integer'
229
+ rule /[-+]?\d+\.?#{terminated}/, Num::Integer
230
+ rule %r([-+]?\d+/\d+#{terminated}), Num::Integer
231
231
  rule %r(
232
232
  [-+]?
233
233
  (\d*\.\d+([defls][-+]?\d+)?
234
234
  |\d+(\.\d*)?[defls][-+]?\d+)
235
235
  #{terminated}
236
- )x, 'Literal.Number.Float'
236
+ )x, Num::Float
237
237
 
238
238
  # sharpsign strings and characters
239
- rule /#\\.#{terminated}/, 'Literal.String.Char'
240
- rule /#\\#{symbol}/, 'Literal.String.Char'
239
+ rule /#\\.#{terminated}/, Str::Char
240
+ rule /#\\#{symbol}/, Str::Char
241
241
 
242
- rule /#\(/, 'Operator', :root
242
+ rule /#\(/, Operator, :root
243
243
 
244
244
  # bitstring
245
- rule /#\d*\*[01]*/, 'Literal.Other'
245
+ rule /#\d*\*[01]*/, Other
246
246
 
247
247
  # uninterned symbol
248
- rule /#:#{symbol}/, 'Literal.String.Symbol'
248
+ rule /#:#{symbol}/, Str::Symbol
249
249
 
250
250
  # read-time and load-time evaluation
251
- rule /#[.,]/, 'Operator'
251
+ rule /#[.,]/, Operator
252
252
 
253
253
  # function shorthand
254
- rule /#'/, 'Name.Function'
254
+ rule /#'/, Name::Function
255
255
 
256
256
  # binary rational
257
- rule /#b[+-]?[01]+(\/[01]+)?/i, 'Literal.Number'
257
+ rule /#b[+-]?[01]+(\/[01]+)?/i, Num
258
258
 
259
259
  # octal rational
260
- rule /#o[+-]?[0-7]+(\/[0-7]+)?/i, 'Literal.Number.Oct'
260
+ rule /#o[+-]?[0-7]+(\/[0-7]+)?/i, Num::Oct
261
261
 
262
262
  # hex rational
263
- rule /#x[+-]?[0-9a-f]+(\/[0-9a-f]+)?/i, 'Literal.Number'
263
+ rule /#x[+-]?[0-9a-f]+(\/[0-9a-f]+)?/i, Num
264
264
 
265
265
  # complex
266
266
  rule /(#c)(\()/i do
267
- group 'Literal.Number'
268
- group 'Punctuation'
267
+ group Num
268
+ group Punctuation
269
269
  push :root
270
270
  end
271
271
 
272
272
  # arrays and structures
273
273
  rule /(#(?:\d+a|s))(\()/i do
274
- group 'Literal.Other'
275
- group 'Punctuation'
274
+ group Literal::Other
275
+ group Punctuation
276
276
  push :root
277
277
  end
278
278
 
@@ -280,66 +280,67 @@ module Rouge
280
280
  rule /#p?"(\\.|[^"])*"/i
281
281
 
282
282
  # reference
283
- rule /#\d+[=#]/, 'Operator'
283
+ rule /#\d+[=#]/, Operator
284
284
 
285
285
  # read-time comment
286
- rule /#+nil#{terminated}\s*\(/, 'Comment.Preproc', :commented_form
286
+ rule /#+nil#{terminated}\s*\(/, Comment, :commented_form
287
287
 
288
288
  # read-time conditional
289
- rule /#[+-]/, 'Operator'
289
+ rule /#[+-]/, Operator
290
290
 
291
291
  # special operators that should have been parsed already
292
- rule /(,@|,|\.)/, 'Operator'
292
+ rule /(,@|,|\.)/, Operator
293
293
 
294
294
  # special constants
295
- rule /(t|nil)#{terminated}/, 'Name.Constant'
295
+ rule /(t|nil)#{terminated}/, Name::Constant
296
296
 
297
297
  # functions and variables
298
298
  # note that these get filtered through in stream_tokens
299
- rule /\*#{symbol}\*/, 'Name.Variable.Global'
299
+ rule /\*#{symbol}\*/, Name::Variable::Global
300
300
  rule symbol do |m|
301
301
  sym = m[0]
302
302
 
303
303
  if BUILTIN_FUNCTIONS.include? sym
304
- token 'Name.Builtin'
304
+ token Name::Builtin
305
305
  elsif SPECIAL_FORMS.include? sym
306
- token 'Keyword'
306
+ token Keyword
307
307
  elsif MACROS.include? sym
308
- token 'Name.Builtin'
308
+ token Name::Builtin
309
309
  elsif LAMBDA_LIST_KEYWORDS.include? sym
310
- token 'Keyword'
310
+ token Keyword
311
311
  elsif DECLARATIONS.include? sym
312
- token 'Keyword'
312
+ token Keyword
313
313
  elsif BUILTIN_TYPES.include? sym
314
- token 'Keyword.Type'
314
+ token Keyword::Type
315
315
  elsif BUILTIN_CLASSES.include? sym
316
- token 'Name.Class'
316
+ token Name::Class
317
317
  else
318
- token 'Name.Variable'
318
+ token Name::Variable
319
319
  end
320
320
  end
321
321
 
322
- rule /\(/, 'Punctuation', :root
323
- rule /\)/, 'Punctuation' do
322
+ rule /\(/, Punctuation, :root
323
+ rule /\)/, Punctuation do
324
324
  if stack.empty?
325
- token 'Error'
325
+ token Error
326
326
  else
327
- token 'Punctuation'
327
+ token Punctuation
328
328
  pop!
329
329
  end
330
330
  end
331
331
  end
332
332
 
333
333
  state :multiline_comment do
334
- rule /#\|/, 'Comment.Multiline', :multiline_comment
335
- rule /\|#/, 'Comment.Multiline', :pop!
336
- rule /[^\|#]+/, 'Comment.Multiline'
337
- rule /[\|#]/, 'Comment.Multiline'
334
+ rule /#\|/, Comment::Multiline, :multiline_comment
335
+ rule /\|#/, Comment::Multiline, :pop!
336
+ rule /[^\|#]+/, Comment::Multiline
337
+ rule /[\|#]/, Comment::Multiline
338
338
  end
339
339
 
340
340
  state :commented_form do
341
- rule /\(/, 'Comment.Preproc', :commented_form
342
- rule /\)/, 'Comment.Preproc', :pop!
341
+ rule /\(/, Comment, :commented_form
342
+ rule /\)/, Comment, :pop!
343
+ rule /[^()]+/, Comment
343
344
  end
344
345
  end
345
346
  end
@@ -9,12 +9,12 @@ module Rouge
9
9
 
10
10
  # short and sweet
11
11
  state :root do
12
- rule /#.*?\n/, 'Comment'
13
- rule /".*?"/, 'Literal.String.Double'
14
- rule /'.*?'/, 'Literal.String.Single'
15
- rule /[a-z]\w*/i, 'Name'
16
- rule /\d+/, 'Literal.Number'
17
- rule /[^\d\w#"']+/, 'Text'
12
+ rule /#.*?\n/, Comment
13
+ rule /".*?"/, Str::Double
14
+ rule /'.*?'/, Str::Single
15
+ rule /[a-z]\w*/i, Name
16
+ rule /\d+/, Num
17
+ rule /[^\d\w#"']+/, Text
18
18
  end
19
19
  end
20
20
  end
@@ -53,105 +53,105 @@ module Rouge
53
53
  state :bol do
54
54
  mixin :inline_whitespace
55
55
  rule /#if\s+0/ do
56
- token 'Comment.Preproc'
57
- pop!; push :if_0
56
+ token Comment::Preproc
57
+ goto :if_0
58
58
  end
59
59
 
60
60
  rule /#/ do
61
- token 'Comment.Preproc'
62
- pop!; push :macro
61
+ token Comment::Preproc
62
+ goto :macro
63
63
  end
64
64
 
65
65
  rule(//) { pop! }
66
66
  end
67
67
 
68
68
  state :inline_whitespace do
69
- rule /[ \t\r]+/, 'Text'
70
- rule /\\\n/, 'Text'
71
- rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, 'Comment.Multiline'
69
+ rule /[ \t\r]+/, Text
70
+ rule /\\\n/, Text
71
+ rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
72
72
  end
73
73
 
74
74
  state :whitespace do
75
75
  mixin :inline_whitespace
76
- rule %r(/(\\\n)?/(\n|(.|\n)*?[^\\]\n)), 'Comment.Single', :bol
77
- rule /\n/, 'Text', :bol
76
+ rule %r(/(\\\n)?/(\n|(.|\n)*?[^\\]\n)), Comment::Single, :bol
77
+ rule /\n/, Text, :bol
78
78
  end
79
79
 
80
80
  state :multiline_comment do
81
- rule %r([*](\\\n)?/), 'Comment.Multiline', :pop!
82
- rule %r([*]), 'Comment.Multiline'
83
- rule %r([^*]+), 'Comment.Multiline'
81
+ rule %r([*](\\\n)?/), Comment::Multiline, :pop!
82
+ rule %r([*]), Comment::Multiline
83
+ rule %r([^*]+), Comment::Multiline
84
84
  end
85
85
 
86
86
  state :root do
87
87
  mixin :whitespace
88
88
 
89
- rule /L?"/, 'Literal.String', :string
90
- rule %r(L?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, 'Literal.String.Char'
91
- rule %r((\d+\.\d*|\.\d+|\d+)[e][+-]?\d+[lu]*)i, 'Literal.Number.Float'
92
- rule /0x[0-9a-f]+[lu]*/i, 'Literal.Number.Hex'
93
- rule /0[0-7]+[lu]*/i, 'Literal.Number.Oct'
94
- rule /\d+[lu]*/i, 'Literal.Number.Integer'
95
- rule %r(\*/), 'Error'
96
- rule %r([~!%^&*+=\|?:<>/-]), 'Operator'
97
- rule /[()\[\],.;{}]/, 'Punctuation'
89
+ rule /L?"/, Str, :string
90
+ rule %r(L?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char
91
+ rule %r((\d+\.\d*|\.\d+|\d+)[e][+-]?\d+[lu]*)i, Num::Float
92
+ rule /0x[0-9a-f]+[lu]*/i, Num::Hex
93
+ rule /0[0-7]+[lu]*/i, Num::Oct
94
+ rule /\d+[lu]*/i, Num::Integer
95
+ rule %r(\*/), Error
96
+ rule %r([~!%^&*+=\|?:<>/-]), Operator
97
+ rule /[()\[\],.;{}]/, Punctuation
98
98
 
99
- rule /class\b/, 'Keyword', :classname
99
+ rule /class\b/, Keyword, :classname
100
100
 
101
101
  # Offload C++ extensions, http://offload.codeplay.com/
102
- rule /(?:__offload|__blockingoffload|__outer)\b/, 'Keyword.Pseudo'
102
+ rule /(?:__offload|__blockingoffload|__outer)\b/, Keyword::Pseudo
103
103
 
104
- rule /(true|false)\b/, 'Keyword.Constant'
105
- rule /NULL\b/, 'Name.Builtin'
106
- rule /#{id}:(?!:)/, 'Name.Label'
104
+ rule /(true|false)\b/, Keyword::Constant
105
+ rule /NULL\b/, Name::Builtin
106
+ rule /#{id}:(?!:)/, Name::Label
107
107
  rule id do |m|
108
108
  name = m[0]
109
109
 
110
110
  if self.class.keywords.include? name
111
- token 'Keyword'
111
+ token Keyword
112
112
  elsif self.class.keywords_type.include? name
113
- token 'Keyword.Type'
113
+ token Keyword::Type
114
114
  elsif self.class.reserved.include? name
115
- token 'Keyword.Reserved'
115
+ token Keyword::Reserved
116
116
  else
117
- token 'Name'
117
+ token Name
118
118
  end
119
119
  end
120
120
  end
121
121
 
122
122
  state :classname do
123
- rule id, 'Name.Class', :pop!
123
+ rule id, Name::Class, :pop!
124
124
 
125
125
  # template specification
126
- rule /\s*(?=>)/m, 'Text', :pop!
126
+ rule /\s*(?=>)/m, Text, :pop!
127
127
  mixin :whitespace
128
128
  end
129
129
 
130
130
  state :string do
131
- rule /"/, 'Literal.String', :pop!
132
- rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, 'Literal.String.Escape'
133
- rule /[^\\"\n]+/, 'Literal.String'
134
- rule /\\\n/, 'Literal.String'
135
- rule /\\/, 'Literal.String' # stray backslash
131
+ rule /"/, Str, :pop!
132
+ rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
133
+ rule /[^\\"\n]+/, Str
134
+ rule /\\\n/, Str
135
+ rule /\\/, Str # stray backslash
136
136
  end
137
137
 
138
138
  state :macro do
139
- rule %r([^/\n]+), 'Comment.Preproc'
140
- rule %r(/[*].*?[*]/)m, 'Comment.Multiliine'
141
- rule %r(//.*$), 'Comment.Single'
142
- rule %r(/), 'Comment.Preproc'
143
- rule /(?<=\\)\n/, 'Comment.Preproc'
139
+ rule %r([^/\n]+), Comment::Preproc
140
+ rule %r(/[*].*?[*]/)m, Comment::Multiline
141
+ rule %r(//.*$), Comment::Single
142
+ rule %r(/), Comment::Preproc
143
+ rule /(?<=\\)\n/, Comment::Preproc
144
144
  rule /\n/ do
145
- token 'Comment.Preproc'
146
- pop!; push :bol
145
+ token Comment::Preproc
146
+ goto :bol
147
147
  end
148
148
  end
149
149
 
150
150
  state :if_0 do
151
- rule /^\s*#if.*?(?<!\\)\n/, 'Comment.Preproc', :if_0
152
- rule /^\s*#el(?:se|if).*\n/, 'Comment.Preproc', :pop!
153
- rule /^\s*#endif.*?(?<!\\)\n/, 'Comment.Preproc', :pop!
154
- rule /.*?\n/, 'Comment'
151
+ rule /^\s*#if.*?(?<!\\)\n/, Comment::Preproc, :if_0
152
+ rule /^\s*#el(?:se|if).*\n/, Comment::Preproc, :pop!
153
+ rule /^\s*#endif.*?(?<!\\)\n/, Comment::Preproc, :pop!
154
+ rule /.*?\n/, Comment
155
155
  end
156
156
  end
157
157
  end
@@ -30,52 +30,52 @@ module Rouge
30
30
  )
31
31
 
32
32
  state :whitespace do
33
- rule /\s+/m, 'Text'
34
- rule %r(//.*?\n), 'Comment.Single'
35
- rule %r(/[*].*?[*]/)m, 'Comment.Multiline'
33
+ rule /\s+/m, Text
34
+ rule %r(//.*?\n), Comment::Single
35
+ rule %r(/[*].*?[*]/)m, Comment::Multiline
36
36
  end
37
37
 
38
38
  state :root do
39
39
  mixin :whitespace
40
40
 
41
- rule /^\s*\[.*?\]/, 'Name.Attribute'
42
- rule /[$]\s*"/, 'Literal.String', :splice_string
43
- rule /[$]\s*<#/, 'Literal.String', :splice_recstring
44
- rule /<#/, 'Literal.String', :recstring
41
+ rule /^\s*\[.*?\]/, Name::Attribute
42
+ rule /[$]\s*"/, Str, :splice_string
43
+ rule /[$]\s*<#/, Str, :splice_recstring
44
+ rule /<#/, Str, :recstring
45
45
 
46
- rule /(<\[)\s*(#{id}:)?/, 'Keyword'
47
- rule /\]>/, 'Keyword'
46
+ rule /(<\[)\s*(#{id}:)?/, Keyword
47
+ rule /\]>/, Keyword
48
48
 
49
- rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, 'Punctuation'
50
- rule /@"(\\.|.)*?"/, 'Literal.String'
51
- rule /"(\\.|.)*?["\n]/, 'Literal.String'
52
- rule /'(\\.|.)'/, 'Literal.String.Char'
53
- rule /0x[0-9a-f]+[lu]?/i, 'Literal.Number'
49
+ rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
50
+ rule /@"(\\.|.)*?"/, Str
51
+ rule /"(\\.|.)*?["\n]/, Str
52
+ rule /'(\\.|.)'/, Str::Char
53
+ rule /0x[0-9a-f]+[lu]?/i, Num
54
54
  rule %r(
55
55
  [0-9]
56
56
  ([.][0-9]*)? # decimal
57
57
  (e[+-][0-9]+)? # exponent
58
58
  [fldu]? # type
59
- )ix, 'Literal.Number'
59
+ )ix, Num
60
60
  rule /^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
61
- 'Comment.Preproc'
62
- rule /\b(#{keywords.join('|')})\b/, 'Keyword'
63
- rule /\b(#{keywords_type.join('|')})\b/, 'Keyword.Type'
64
- rule /class|struct/, 'Keyword', :class
65
- rule /namespace|using/, 'Keyword', :namespace
66
- rule /#{id}(?=\s*[(])/, 'Name.Function'
67
- rule id, 'Name'
61
+ Comment::Preproc
62
+ rule /\b(#{keywords.join('|')})\b/, Keyword
63
+ rule /\b(#{keywords_type.join('|')})\b/, Keyword::Type
64
+ rule /class|struct/, Keyword, :class
65
+ rule /namespace|using/, Keyword, :namespace
66
+ rule /#{id}(?=\s*[(])/, Name::Function
67
+ rule id, Name
68
68
  end
69
69
 
70
70
  state :class do
71
71
  mixin :whitespace
72
- rule id, 'Name.Class', :pop!
72
+ rule id, Name::Class, :pop!
73
73
  end
74
74
 
75
75
  state :namespace do
76
76
  mixin :whitespace
77
- rule /(?=[(])/, 'Text', :pop!
78
- rule /(#{id}|[.])+/, 'Name.Namespace', :pop!
77
+ rule /(?=[(])/, Text, :pop!
78
+ rule /(#{id}|[.])+/, Name::Namespace, :pop!
79
79
  end
80
80
 
81
81
  end
@@ -181,38 +181,38 @@ module Rouge
181
181
 
182
182
  state :root do
183
183
  mixin :basics
184
- rule /{/, 'Punctuation', :stanza
185
- rule /:#{identifier}/, 'Name.Decorator'
186
- rule /\.#{identifier}/, 'Name.Class'
187
- rule /##{identifier}/, 'Name.Function'
188
- rule /@#{identifier}/, 'Keyword', :at_rule
189
- rule identifier, 'Name.Tag'
190
- rule %r([~^*!%&\[\]()<>|+=@:;,./?-]), 'Operator'
184
+ rule /{/, Punctuation, :stanza
185
+ rule /:#{identifier}/, Name::Decorator
186
+ rule /\.#{identifier}/, Name::Class
187
+ rule /##{identifier}/, Name::Function
188
+ rule /@#{identifier}/, Keyword, :at_rule
189
+ rule identifier, Name::Tag
190
+ rule %r([~^*!%&\[\]()<>|+=@:;,./?-]), Operator
191
191
  end
192
192
 
193
193
  state :value do
194
194
  mixin :basics
195
- rule /url\(.*?\)/, 'Literal.String.Other'
196
- rule /#[0-9a-f]{1,6}/i, 'Literal.Number' # colors
197
- rule /#{number}(?:em|px|%|pt|pc|in|mm|m|ex|s)?\b/, 'Literal.Number'
198
- rule /[\[\]():\/.,]/, 'Punctuation'
199
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String.Single'
200
- rule /'(\\\\|\\'|[^'])*'/, 'Literal.String.Double'
195
+ rule /url\(.*?\)/, Str::Other
196
+ rule /#[0-9a-f]{1,6}/i, Num # colors
197
+ rule /#{number}(?:em|px|%|pt|pc|in|mm|m|ex|s)?\b/, Num
198
+ rule /[\[\]():\/.,]/, Punctuation
199
+ rule /"(\\\\|\\"|[^"])*"/, Str::Single
200
+ rule /'(\\\\|\\'|[^'])*'/, Str::Double
201
201
  rule(identifier) do |m|
202
202
  if self.class.constants.include? m[0]
203
- token 'Name.Constant'
203
+ token Name::Constant
204
204
  elsif self.class.builtins.include? m[0]
205
- token 'Name.Builtin'
205
+ token Name::Builtin
206
206
  else
207
- token 'Name'
207
+ token Name
208
208
  end
209
209
  end
210
210
  end
211
211
 
212
212
  state :at_rule do
213
- rule /{(?=\s*#{identifier}\s*:)/m, 'Punctuation', :at_stanza
214
- rule /{/, 'Punctuation', :at_body
215
- rule /;/, 'Punctuation', :pop!
213
+ rule /{(?=\s*#{identifier}\s*:)/m, Punctuation, :at_stanza
214
+ rule /{/, Punctuation, :at_body
215
+ rule /;/, Punctuation, :pop!
216
216
  mixin :value
217
217
  end
218
218
 
@@ -228,40 +228,39 @@ module Rouge
228
228
 
229
229
  state :at_content do
230
230
  rule /}/ do
231
- token 'Punctuation'
232
- pop!; pop!
231
+ token Punctuation
232
+ pop! 2
233
233
  end
234
234
  end
235
235
 
236
236
  state :basics do
237
- rule /\s+/m, 'Text'
238
- rule %r(/\*(?:.*?)\*/)m, 'Comment'
237
+ rule /\s+/m, Text
238
+ rule %r(/\*(?:.*?)\*/)m, Comment
239
239
  end
240
240
 
241
241
  state :stanza do
242
242
  mixin :basics
243
- rule /}/, 'Punctuation', :pop!
243
+ rule /}/, Punctuation, :pop!
244
244
  rule /(#{identifier})(\s*)(:)/m do |m|
245
- if self.class.attributes.include? m[1]
246
- group 'Name.Label'
245
+ name_tok = if self.class.attributes.include? m[1]
246
+ Name::Label
247
247
  elsif self.class.vendor_prefixes.any? { |p| m[1].start_with?(p) }
248
- group 'Name.Label'
248
+ Name::Label
249
249
  else
250
- group 'Name.Property'
250
+ Name::Property
251
251
  end
252
252
 
253
- group 'Text'
254
- group 'Punctuation'
253
+ groups name_tok, Text, Punctuation
255
254
 
256
255
  push :stanza_value
257
256
  end
258
257
  end
259
258
 
260
259
  state :stanza_value do
261
- rule /;/, 'Punctuation', :pop!
260
+ rule /;/, Punctuation, :pop!
262
261
  rule(/(?=})/) { pop! }
263
- rule /!important\b/, 'Comment.Preproc'
264
- rule /^@.*?$/, 'Comment.Preproc'
262
+ rule /!important\b/, Comment::Preproc
263
+ rule /^@.*?$/, Comment::Preproc
265
264
  mixin :value
266
265
  end
267
266
  end