rouge 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,6 +100,11 @@ module Rouge
100
100
  end
101
101
 
102
102
  state :names do
103
+ rule %r/(?:public|protected|private)\(set\)/i do
104
+ push :in_visibility
105
+ token Keyword
106
+ end
107
+
103
108
  rule %r/#{id_with_ns}(?=\s*\()/ do |m|
104
109
  name = m[0].downcase
105
110
  if self.class.keywords.include? name
@@ -179,7 +184,7 @@ module Rouge
179
184
 
180
185
  # numbers
181
186
  rule %r/(\d[_\d]*)?\.(\d[_\d]*)?(e[+-]?\d[_\d]*)?/i, Num::Float
182
- rule %r/0[0-7][0-7_]*/, Num::Oct
187
+ rule %r/0o?[0-7][0-7_]*/i, Num::Oct
183
188
  rule %r/0b[01][01_]*/i, Num::Bin
184
189
  rule %r/0x[a-f0-9][a-f0-9_]*/i, Num::Hex
185
190
  rule %r/\d[_\d]*/, Num::Integer
@@ -243,6 +248,13 @@ module Rouge
243
248
  groups Keyword::Declaration, Text, Name::Class
244
249
  end
245
250
 
251
+ rule %r/(enum)
252
+ (\s+)
253
+ (#{id_with_ns})/ix do |m|
254
+ groups Keyword::Declaration, Text, Name::Class
255
+ push :in_enum
256
+ end
257
+
246
258
  mixin :names
247
259
 
248
260
  rule %r/[;,\(\)\{\}\[\]]/, Punctuation
@@ -280,6 +292,9 @@ module Rouge
280
292
  end
281
293
 
282
294
  state :in_const do
295
+ rule %r/(\??#{id})(\s+)(#{id})/i do
296
+ groups Keyword::Type, Text, Name::Constant
297
+ end
283
298
  rule id, Name::Constant
284
299
  rule %r/=/, Operator, :in_assign
285
300
  mixin :escape
@@ -307,7 +322,8 @@ module Rouge
307
322
  rule %r/,/, Punctuation
308
323
  rule %r/[.]{3}/, Punctuation
309
324
  rule %r/=/, Operator, :in_assign
310
- rule %r/\b(?:public|protected|private|readonly)\b/i, Keyword
325
+ rule %r/\b(?:public|protected|private|readonly)(?:\(set\)|\b)/i, Keyword
326
+ rule %r/\breadonly\b/i, Keyword
311
327
  rule %r/\??#{id}/, Keyword::Type, :in_assign
312
328
  mixin :escape
313
329
  mixin :whitespace
@@ -369,6 +385,7 @@ module Rouge
369
385
  end
370
386
 
371
387
  state :in_visibility do
388
+ rule %r/\b(?:public|protected|private)(?:\(set\)|\b)/i, Keyword
372
389
  rule %r/\b(?:readonly|static)\b/i, Keyword
373
390
  rule %r/(?=(abstract|const|function)\b)/i, Keyword, :pop!
374
391
  rule %r/\??#{id}/, Keyword::Type, :pop!
@@ -376,6 +393,29 @@ module Rouge
376
393
  mixin :whitespace
377
394
  mixin :return
378
395
  end
396
+
397
+ state :in_enum do
398
+ rule %r/:/, Punctuation, :in_enum_base_type
399
+ rule %r/\{/, Punctuation, :in_enum_body
400
+ mixin :escape
401
+ mixin :whitespace
402
+ mixin :return
403
+ end
404
+
405
+ state :in_enum_base_type do
406
+ rule id, Keyword::Type, :pop!
407
+ mixin :escape
408
+ mixin :whitespace
409
+ mixin :return
410
+ end
411
+
412
+ state :in_enum_body do
413
+ rule %r/\}/, Punctuation, :pop!
414
+ rule %r/(case)(\s+)(#{id})/i do
415
+ groups Keyword, Text, Name::Constant
416
+ end
417
+ mixin :php
418
+ end
379
419
  end
380
420
  end
381
421
  end
@@ -124,7 +124,7 @@ module Rouge
124
124
 
125
125
  # TODO: not in python 3
126
126
  rule %r/`.*?`/, Str::Backtick
127
- rule %r/([rfbu]{0,2})('''|"""|['"])/i do |m|
127
+ rule %r/([rtfbu]{0,2})('''|"""|['"])/i do |m|
128
128
  groups Str::Affix, Str::Heredoc
129
129
  current_string.register type: m[1].downcase, delim: m[2]
130
130
  push :generic_string
@@ -10,7 +10,7 @@ module Rouge
10
10
  title "Robot Framework"
11
11
  desc 'Robot Framework is a generic open source automation testing framework (robotframework.org)'
12
12
 
13
- filenames '*.robot'
13
+ filenames '*.robot', '*.resource'
14
14
  mimetypes 'text/x-robot'
15
15
 
16
16
  def initialize(opts = {})
@@ -297,7 +297,7 @@ module Rouge
297
297
  (
298
298
  [\p{L}_]\p{Word}*[!?]? |
299
299
  \*\*? | [-+]@? | [/%&\|^`~] | \[\]=? |
300
- <<? | >>? | <=>? | >= | ===?
300
+ <=>? | <<? | >>? | >= | ===?
301
301
  )
302
302
  )x do |m|
303
303
  puts "matches: #{[m[0], m[1], m[2], m[3]].inspect}" if @debug
@@ -11,7 +11,7 @@ module Rouge
11
11
 
12
12
  tag 'terraform'
13
13
  aliases 'tf'
14
- filenames '*.tf', '*.tfvars'
14
+ filenames '*.tf', '*.tfvars', '*.tofu'
15
15
 
16
16
  def self.keywords
17
17
  @keywords ||= Set.new %w(
@@ -11,63 +11,56 @@ module Rouge
11
11
  filenames '*.toml', 'Pipfile', 'poetry.lock'
12
12
  mimetypes 'text/x-toml'
13
13
 
14
- # bare keys and quoted keys
15
- identifier = %r/(?:\S+|"[^"]+"|'[^']+')/
16
-
17
- state :basic do
18
- rule %r/\s+/, Text
19
- rule %r/#.*?$/, Comment
20
- rule %r/(true|false)/, Keyword::Constant
21
-
22
- rule %r/(#{identifier})(\s*)(=)(\s*)(\{)/ do
23
- groups Name::Property, Text, Operator, Text, Punctuation
24
- push :inline
25
- end
26
- end
27
-
28
14
  state :root do
29
- mixin :basic
15
+ mixin :whitespace
30
16
 
31
- rule %r/(?<!=)\s*\[.*?\]+/, Name::Namespace
17
+ mixin :key
32
18
 
33
- rule %r/(#{identifier})(\s*)(=)/ do
34
- groups Name::Property, Text, Punctuation
19
+ rule %r/(=)(\s*)/ do
20
+ groups Operator, Text::Whitespace
35
21
  push :value
36
22
  end
37
- end
38
23
 
39
- state :value do
40
- rule %r/\n/, Text, :pop!
41
- mixin :content
24
+ rule %r/\[\[?/, Keyword, :table_key
42
25
  end
43
26
 
44
- state :content do
45
- mixin :basic
46
-
47
- rule %r/(#{identifier})(\s*)(=)/ do
48
- groups Name::Property, Text, Punctuation
49
- end
27
+ state :key do
28
+ rule %r/[A-Za-z0-9_-]+/, Name
50
29
 
51
- rule %r/\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}:\d{2}(?:[Zz]|[+-]\d{2}:\d{2})?)?/, Literal::Date
52
- rule %r/\d{2}:\d{2}:\d{2}/, Literal::Date
53
-
54
- rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
55
- rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float
56
- rule %r/[+-]?(?:nan|inf)/, Num::Float
30
+ rule %r/"/, Str, :dq
31
+ rule %r/'/, Str, :sq
32
+ rule %r/\./, Punctuation
33
+ end
57
34
 
58
- rule %r/0x\h+(?:_\h+)*/, Num::Hex
59
- rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
60
- rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
61
- rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer
35
+ state :table_key do
36
+ rule %r/[A-Za-z0-9_-]+/, Name
62
37
 
63
- rule %r/"""/, Str, :mdq
64
38
  rule %r/"/, Str, :dq
65
- rule %r/'''/, Str, :msq
66
39
  rule %r/'/, Str, :sq
67
- mixin :esc_str
68
- rule %r/\,/, Punctuation
69
- rule %r/\[/, Punctuation, :array
70
- rule %r/\{/, Punctuation, :inline
40
+ rule %r/\./, Keyword
41
+ rule %r/\]\]?/, Keyword, :pop!
42
+ rule %r/[ \t]+/, Text::Whitespace
43
+ end
44
+
45
+ state :value do
46
+ rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date, :pop!
47
+ rule %r/\d\d:\d\d:\d\d(\.\d+)?/, Literal::Date, :pop!
48
+ rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float, :pop!
49
+ rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float, :pop!
50
+ rule %r/[+-]?(?:nan|inf)/, Num::Float, :pop!
51
+ rule %r/0x\h+(?:_\h+)*/, Num::Hex, :pop!
52
+ rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct, :pop!
53
+ rule %r/0b[01]+(?:_[01]+)*/, Num::Bin, :pop!
54
+ rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer, :pop!
55
+
56
+ rule %r/"""/, Str, [:pop!, :mdq]
57
+ rule %r/"/, Str, [:pop!, :dq]
58
+ rule %r/'''/, Str, [:pop!, :msq]
59
+ rule %r/'/, Str, [:pop!, :sq]
60
+
61
+ rule %r/(true|false)/, Keyword::Constant, :pop!
62
+ rule %r/\[/, Punctuation, [:pop!, :array]
63
+ rule %r/\{/, Punctuation, [:pop!, :inline]
71
64
  end
72
65
 
73
66
  state :dq do
@@ -101,15 +94,31 @@ module Rouge
101
94
  end
102
95
 
103
96
  state :array do
104
- mixin :content
97
+ mixin :whitespace
98
+ rule %r/,/, Punctuation
99
+
105
100
  rule %r/\]/, Punctuation, :pop!
101
+
102
+ rule %r//, Token, :value
106
103
  end
107
104
 
108
105
  state :inline do
109
- mixin :content
106
+ rule %r/[ \t]+/, Text::Whitespace
110
107
 
108
+ mixin :key
109
+ rule %r/(=)(\s*)/ do
110
+ groups Punctuation, Text::Whitespace
111
+ push :value
112
+ end
113
+
114
+ rule %r/,/, Punctuation
111
115
  rule %r/\}/, Punctuation, :pop!
112
116
  end
117
+
118
+ state :whitespace do
119
+ rule %r/\s+/, Text
120
+ rule %r/#.*?$/, Comment
121
+ end
113
122
  end
114
123
  end
115
124
  end
data/lib/rouge/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "4.6.0"
6
+ "4.7.0"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
@@ -91,11 +91,13 @@ files:
91
91
  - lib/rouge/demos/ghc-cmm
92
92
  - lib/rouge/demos/ghc-core
93
93
  - lib/rouge/demos/gherkin
94
+ - lib/rouge/demos/gjs
94
95
  - lib/rouge/demos/glsl
95
96
  - lib/rouge/demos/go
96
97
  - lib/rouge/demos/gradle
97
98
  - lib/rouge/demos/graphql
98
99
  - lib/rouge/demos/groovy
100
+ - lib/rouge/demos/gts
99
101
  - lib/rouge/demos/hack
100
102
  - lib/rouge/demos/haml
101
103
  - lib/rouge/demos/handlebars
@@ -341,11 +343,13 @@ files:
341
343
  - lib/rouge/lexers/ghc_core.rb
342
344
  - lib/rouge/lexers/gherkin.rb
343
345
  - lib/rouge/lexers/gherkin/keywords.rb
346
+ - lib/rouge/lexers/gjs.rb
344
347
  - lib/rouge/lexers/glsl.rb
345
348
  - lib/rouge/lexers/go.rb
346
349
  - lib/rouge/lexers/gradle.rb
347
350
  - lib/rouge/lexers/graphql.rb
348
351
  - lib/rouge/lexers/groovy.rb
352
+ - lib/rouge/lexers/gts.rb
349
353
  - lib/rouge/lexers/hack.rb
350
354
  - lib/rouge/lexers/haml.rb
351
355
  - lib/rouge/lexers/handlebars.rb