rouge 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/bin/rougify +1 -1
- data/lib/rouge/demos/{text → plaintext} +0 -0
- data/lib/rouge/formatters/html.rb +13 -8
- data/lib/rouge/formatters/terminal256.rb +15 -11
- data/lib/rouge/lexer.rb +3 -1
- data/lib/rouge/lexers/c.rb +65 -55
- data/lib/rouge/lexers/clojure.rb +19 -19
- data/lib/rouge/lexers/coffeescript.rb +42 -42
- data/lib/rouge/lexers/common_lisp.rb +49 -48
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/cpp.rb +48 -48
- data/lib/rouge/lexers/csharp.rb +25 -25
- data/lib/rouge/lexers/css.rb +32 -33
- data/lib/rouge/lexers/diff.rb +8 -8
- data/lib/rouge/lexers/elixir.rb +30 -30
- data/lib/rouge/lexers/erb.rb +5 -5
- data/lib/rouge/lexers/erlang.rb +38 -38
- data/lib/rouge/lexers/factor.rb +56 -56
- data/lib/rouge/lexers/gherkin.rb +27 -27
- data/lib/rouge/lexers/go.rb +21 -21
- data/lib/rouge/lexers/groovy.rb +32 -32
- data/lib/rouge/lexers/haml.rb +35 -35
- data/lib/rouge/lexers/handlebars.rb +27 -27
- data/lib/rouge/lexers/haskell.rb +78 -79
- data/lib/rouge/lexers/html.rb +28 -28
- data/lib/rouge/lexers/http.rb +13 -13
- data/lib/rouge/lexers/ini.rb +13 -13
- data/lib/rouge/lexers/io.rb +19 -19
- data/lib/rouge/lexers/java.rb +29 -29
- data/lib/rouge/lexers/javascript.rb +49 -52
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +14 -14
- data/lib/rouge/lexers/lua.rb +33 -33
- data/lib/rouge/lexers/make.rb +26 -26
- data/lib/rouge/lexers/markdown.rb +49 -49
- data/lib/rouge/lexers/nginx.rb +19 -19
- data/lib/rouge/lexers/perl.rb +53 -54
- data/lib/rouge/lexers/php.rb +42 -43
- data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
- data/lib/rouge/lexers/prolog.rb +19 -19
- data/lib/rouge/lexers/puppet.rb +40 -40
- data/lib/rouge/lexers/python.rb +63 -63
- data/lib/rouge/lexers/r.rb +15 -15
- data/lib/rouge/lexers/racket.rb +29 -29
- data/lib/rouge/lexers/ruby.rb +94 -97
- data/lib/rouge/lexers/rust.rb +37 -37
- data/lib/rouge/lexers/sass.rb +15 -15
- data/lib/rouge/lexers/sass/common.rb +144 -136
- data/lib/rouge/lexers/scheme.rb +25 -25
- data/lib/rouge/lexers/scss.rb +7 -7
- data/lib/rouge/lexers/sed.rb +39 -39
- data/lib/rouge/lexers/shell.rb +45 -45
- data/lib/rouge/lexers/smalltalk.rb +36 -36
- data/lib/rouge/lexers/sql.rb +27 -27
- data/lib/rouge/lexers/tcl.rb +34 -34
- data/lib/rouge/lexers/tex.rb +24 -24
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/viml.rb +19 -19
- data/lib/rouge/lexers/xml.rb +16 -16
- data/lib/rouge/lexers/yaml.rb +78 -81
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/regex_lexer.rb +31 -14
- data/lib/rouge/template_lexer.rb +1 -1
- data/lib/rouge/theme.rb +12 -10
- data/lib/rouge/themes/thankful_eyes.rb +43 -43
- data/lib/rouge/token.rb +145 -148
- data/lib/rouge/version.rb +1 -1
- 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,
|
218
|
-
rule /;.*$/,
|
219
|
-
rule /#\|/,
|
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.*$/,
|
223
|
-
rule /"(\\.|[^"\\])*"/,
|
222
|
+
rule /#\d*Y.*$/, Comment::Special
|
223
|
+
rule /"(\\.|[^"\\])*"/, Str
|
224
224
|
|
225
|
-
rule /[:']#{symbol}/,
|
226
|
-
rule /['`]/,
|
225
|
+
rule /[:']#{symbol}/, Str::Symbol
|
226
|
+
rule /['`]/, Operator
|
227
227
|
|
228
228
|
# numbers
|
229
|
-
rule /[-+]?\d+\.?#{terminated}/,
|
230
|
-
rule %r([-+]?\d+/\d+#{terminated}),
|
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,
|
236
|
+
)x, Num::Float
|
237
237
|
|
238
238
|
# sharpsign strings and characters
|
239
|
-
rule /#\\.#{terminated}/,
|
240
|
-
rule /#\\#{symbol}/,
|
239
|
+
rule /#\\.#{terminated}/, Str::Char
|
240
|
+
rule /#\\#{symbol}/, Str::Char
|
241
241
|
|
242
|
-
rule /#\(/,
|
242
|
+
rule /#\(/, Operator, :root
|
243
243
|
|
244
244
|
# bitstring
|
245
|
-
rule /#\d*\*[01]*/,
|
245
|
+
rule /#\d*\*[01]*/, Other
|
246
246
|
|
247
247
|
# uninterned symbol
|
248
|
-
rule /#:#{symbol}/,
|
248
|
+
rule /#:#{symbol}/, Str::Symbol
|
249
249
|
|
250
250
|
# read-time and load-time evaluation
|
251
|
-
rule /#[.,]/,
|
251
|
+
rule /#[.,]/, Operator
|
252
252
|
|
253
253
|
# function shorthand
|
254
|
-
rule /#'/,
|
254
|
+
rule /#'/, Name::Function
|
255
255
|
|
256
256
|
# binary rational
|
257
|
-
rule /#b[+-]?[01]+(\/[01]+)?/i,
|
257
|
+
rule /#b[+-]?[01]+(\/[01]+)?/i, Num
|
258
258
|
|
259
259
|
# octal rational
|
260
|
-
rule /#o[+-]?[0-7]+(\/[0-7]+)?/i,
|
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,
|
263
|
+
rule /#x[+-]?[0-9a-f]+(\/[0-9a-f]+)?/i, Num
|
264
264
|
|
265
265
|
# complex
|
266
266
|
rule /(#c)(\()/i do
|
267
|
-
group
|
268
|
-
group
|
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
|
275
|
-
group
|
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+[=#]/,
|
283
|
+
rule /#\d+[=#]/, Operator
|
284
284
|
|
285
285
|
# read-time comment
|
286
|
-
rule /#+nil#{terminated}\s*\(/,
|
286
|
+
rule /#+nil#{terminated}\s*\(/, Comment, :commented_form
|
287
287
|
|
288
288
|
# read-time conditional
|
289
|
-
rule /#[+-]/,
|
289
|
+
rule /#[+-]/, Operator
|
290
290
|
|
291
291
|
# special operators that should have been parsed already
|
292
|
-
rule /(,@|,|\.)/,
|
292
|
+
rule /(,@|,|\.)/, Operator
|
293
293
|
|
294
294
|
# special constants
|
295
|
-
rule /(t|nil)#{terminated}/,
|
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}\*/,
|
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
|
304
|
+
token Name::Builtin
|
305
305
|
elsif SPECIAL_FORMS.include? sym
|
306
|
-
token
|
306
|
+
token Keyword
|
307
307
|
elsif MACROS.include? sym
|
308
|
-
token
|
308
|
+
token Name::Builtin
|
309
309
|
elsif LAMBDA_LIST_KEYWORDS.include? sym
|
310
|
-
token
|
310
|
+
token Keyword
|
311
311
|
elsif DECLARATIONS.include? sym
|
312
|
-
token
|
312
|
+
token Keyword
|
313
313
|
elsif BUILTIN_TYPES.include? sym
|
314
|
-
token
|
314
|
+
token Keyword::Type
|
315
315
|
elsif BUILTIN_CLASSES.include? sym
|
316
|
-
token
|
316
|
+
token Name::Class
|
317
317
|
else
|
318
|
-
token
|
318
|
+
token Name::Variable
|
319
319
|
end
|
320
320
|
end
|
321
321
|
|
322
|
-
rule /\(/,
|
323
|
-
rule /\)/,
|
322
|
+
rule /\(/, Punctuation, :root
|
323
|
+
rule /\)/, Punctuation do
|
324
324
|
if stack.empty?
|
325
|
-
token
|
325
|
+
token Error
|
326
326
|
else
|
327
|
-
token
|
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 /#\|/,
|
335
|
-
rule /\|#/,
|
336
|
-
rule /[^\|#]+/,
|
337
|
-
rule /[\|#]/,
|
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 /\(/,
|
342
|
-
rule /\)/,
|
341
|
+
rule /\(/, Comment, :commented_form
|
342
|
+
rule /\)/, Comment, :pop!
|
343
|
+
rule /[^()]+/, Comment
|
343
344
|
end
|
344
345
|
end
|
345
346
|
end
|
data/lib/rouge/lexers/conf.rb
CHANGED
@@ -9,12 +9,12 @@ module Rouge
|
|
9
9
|
|
10
10
|
# short and sweet
|
11
11
|
state :root do
|
12
|
-
rule /#.*?\n/,
|
13
|
-
rule /".*?"/,
|
14
|
-
rule /'.*?'/,
|
15
|
-
rule /[a-z]\w*/i,
|
16
|
-
rule /\d+/,
|
17
|
-
rule /[^\d\w#"']+/,
|
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
|
data/lib/rouge/lexers/cpp.rb
CHANGED
@@ -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
|
57
|
-
|
56
|
+
token Comment::Preproc
|
57
|
+
goto :if_0
|
58
58
|
end
|
59
59
|
|
60
60
|
rule /#/ do
|
61
|
-
token
|
62
|
-
|
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]+/,
|
70
|
-
rule /\\\n/,
|
71
|
-
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m,
|
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)),
|
77
|
-
rule /\n/,
|
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)?/),
|
82
|
-
rule %r([*]),
|
83
|
-
rule %r([^*]+),
|
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?"/,
|
90
|
-
rule %r(L?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i,
|
91
|
-
rule %r((\d+\.\d*|\.\d+|\d+)[e][+-]?\d+[lu]*)i,
|
92
|
-
rule /0x[0-9a-f]+[lu]*/i,
|
93
|
-
rule /0[0-7]+[lu]*/i,
|
94
|
-
rule /\d+[lu]*/i,
|
95
|
-
rule %r(\*/),
|
96
|
-
rule %r([~!%^&*+=\|?:<>/-]),
|
97
|
-
rule /[()\[\],.;{}]/,
|
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/,
|
99
|
+
rule /class\b/, Keyword, :classname
|
100
100
|
|
101
101
|
# Offload C++ extensions, http://offload.codeplay.com/
|
102
|
-
rule /(?:__offload|__blockingoffload|__outer)\b/,
|
102
|
+
rule /(?:__offload|__blockingoffload|__outer)\b/, Keyword::Pseudo
|
103
103
|
|
104
|
-
rule /(true|false)\b/,
|
105
|
-
rule /NULL\b/,
|
106
|
-
rule /#{id}:(?!:)/,
|
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
|
111
|
+
token Keyword
|
112
112
|
elsif self.class.keywords_type.include? name
|
113
|
-
token
|
113
|
+
token Keyword::Type
|
114
114
|
elsif self.class.reserved.include? name
|
115
|
-
token
|
115
|
+
token Keyword::Reserved
|
116
116
|
else
|
117
|
-
token
|
117
|
+
token Name
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
state :classname do
|
123
|
-
rule id,
|
123
|
+
rule id, Name::Class, :pop!
|
124
124
|
|
125
125
|
# template specification
|
126
|
-
rule /\s*(?=>)/m,
|
126
|
+
rule /\s*(?=>)/m, Text, :pop!
|
127
127
|
mixin :whitespace
|
128
128
|
end
|
129
129
|
|
130
130
|
state :string do
|
131
|
-
rule /"/,
|
132
|
-
rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/,
|
133
|
-
rule /[^\\"\n]+/,
|
134
|
-
rule /\\\n/,
|
135
|
-
rule /\\/,
|
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]+),
|
140
|
-
rule %r(/[*].*?[*]/)m,
|
141
|
-
rule %r(//.*$),
|
142
|
-
rule %r(/),
|
143
|
-
rule /(?<=\\)\n/,
|
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
|
146
|
-
|
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/,
|
152
|
-
rule /^\s*#el(?:se|if).*\n/,
|
153
|
-
rule /^\s*#endif.*?(?<!\\)\n/,
|
154
|
-
rule /.*?\n/,
|
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
|
data/lib/rouge/lexers/csharp.rb
CHANGED
@@ -30,52 +30,52 @@ module Rouge
|
|
30
30
|
)
|
31
31
|
|
32
32
|
state :whitespace do
|
33
|
-
rule /\s+/m,
|
34
|
-
rule %r(//.*?\n),
|
35
|
-
rule %r(/[*].*?[*]/)m,
|
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*\[.*?\]/,
|
42
|
-
rule /[$]\s*"/,
|
43
|
-
rule /[$]\s*<#/,
|
44
|
-
rule /<#/,
|
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}:)?/,
|
47
|
-
rule /\]>/,
|
46
|
+
rule /(<\[)\s*(#{id}:)?/, Keyword
|
47
|
+
rule /\]>/, Keyword
|
48
48
|
|
49
|
-
rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/,
|
50
|
-
rule /@"(\\.|.)*?"/,
|
51
|
-
rule /"(\\.|.)*?["\n]/,
|
52
|
-
rule /'(\\.|.)'/,
|
53
|
-
rule /0x[0-9a-f]+[lu]?/i,
|
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,
|
59
|
+
)ix, Num
|
60
60
|
rule /^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
|
61
|
-
|
62
|
-
rule /\b(#{keywords.join('|')})\b/,
|
63
|
-
rule /\b(#{keywords_type.join('|')})\b/,
|
64
|
-
rule /class|struct/,
|
65
|
-
rule /namespace|using/,
|
66
|
-
rule /#{id}(?=\s*[(])/,
|
67
|
-
rule id,
|
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,
|
72
|
+
rule id, Name::Class, :pop!
|
73
73
|
end
|
74
74
|
|
75
75
|
state :namespace do
|
76
76
|
mixin :whitespace
|
77
|
-
rule /(?=[(])/,
|
78
|
-
rule /(#{id}|[.])+/,
|
77
|
+
rule /(?=[(])/, Text, :pop!
|
78
|
+
rule /(#{id}|[.])+/, Name::Namespace, :pop!
|
79
79
|
end
|
80
80
|
|
81
81
|
end
|
data/lib/rouge/lexers/css.rb
CHANGED
@@ -181,38 +181,38 @@ module Rouge
|
|
181
181
|
|
182
182
|
state :root do
|
183
183
|
mixin :basics
|
184
|
-
rule /{/,
|
185
|
-
rule /:#{identifier}/,
|
186
|
-
rule /\.#{identifier}/,
|
187
|
-
rule /##{identifier}/,
|
188
|
-
rule /@#{identifier}/,
|
189
|
-
rule identifier,
|
190
|
-
rule %r([~^*!%&\[\]()<>|+=@:;,./?-]),
|
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\(.*?\)/,
|
196
|
-
rule /#[0-9a-f]{1,6}/i,
|
197
|
-
rule /#{number}(?:em|px|%|pt|pc|in|mm|m|ex|s)?\b/,
|
198
|
-
rule /[\[\]():\/.,]/,
|
199
|
-
rule /"(\\\\|\\"|[^"])*"/,
|
200
|
-
rule /'(\\\\|\\'|[^'])*'/,
|
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
|
203
|
+
token Name::Constant
|
204
204
|
elsif self.class.builtins.include? m[0]
|
205
|
-
token
|
205
|
+
token Name::Builtin
|
206
206
|
else
|
207
|
-
token
|
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,
|
214
|
-
rule /{/,
|
215
|
-
rule /;/,
|
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
|
232
|
-
pop
|
231
|
+
token Punctuation
|
232
|
+
pop! 2
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
236
|
state :basics do
|
237
|
-
rule /\s+/m,
|
238
|
-
rule %r(/\*(?:.*?)\*/)m,
|
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 /}/,
|
243
|
+
rule /}/, Punctuation, :pop!
|
244
244
|
rule /(#{identifier})(\s*)(:)/m do |m|
|
245
|
-
if self.class.attributes.include? m[1]
|
246
|
-
|
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
|
-
|
248
|
+
Name::Label
|
249
249
|
else
|
250
|
-
|
250
|
+
Name::Property
|
251
251
|
end
|
252
252
|
|
253
|
-
|
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 /;/,
|
260
|
+
rule /;/, Punctuation, :pop!
|
262
261
|
rule(/(?=})/) { pop! }
|
263
|
-
rule /!important\b/,
|
264
|
-
rule /^@.*?$/,
|
262
|
+
rule /!important\b/, Comment::Preproc
|
263
|
+
rule /^@.*?$/, Comment::Preproc
|
265
264
|
mixin :value
|
266
265
|
end
|
267
266
|
end
|