rouge 4.5.2 → 4.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e05ab679798a94f2f0eb8c949c3cd9bedcebb041d41cdaad5531d58782747ba4
4
- data.tar.gz: 8885464dab437455ef92b154b22fc142783620a1e8f5c5259e398cbbd5a575a4
3
+ metadata.gz: 83340a3ee45685522d7b91daf3d85c87721430d3606ab761353099941f272f4e
4
+ data.tar.gz: 112aa358b29944ddbba5d837ae32bcd833a7c5c9d9b4100a952a265dc9c5459c
5
5
  SHA512:
6
- metadata.gz: '0781c8f63f7e851cb6248ffbd713630e00206730ec3b590e41cbd5fc019597113ea5b2bb1108fff504c1055f9245716bbf9bcf69c89cd5259665e31ac96b6b4c'
7
- data.tar.gz: 67e402cb9f3ff585824b8a888d5cf7be538f32ded5613af14f2381661c74b2c426d215d5e9f886577eca61233d7f7ac884c11e12fe9b191e18e3ea9063d03945
6
+ metadata.gz: d266d81096d98c4cbd51d0cc79edef8887a40465e749bfc51d32ae0a493b0be23e090234336a8accfdfe45d48e4a25d4bd50391f369d8901c5a1ec946071d604
7
+ data.tar.gz: 011ff0045c3de53ca6e1647651d3fe8cd722a57656d3d08ca4559a1dfb40b3940162c6502ff71ead6ebe0ff95a60e8924d2d50ee5c0b144bff344a6392563f7c
data/Gemfile CHANGED
@@ -35,4 +35,7 @@ group :development do
35
35
  # Ruby 3 no longer ships with a web server
36
36
  gem 'puma' if RUBY_VERSION >= '3'
37
37
  gem 'shotgun'
38
+
39
+ gem "mutex_m" if RUBY_VERSION >= '3.4'
40
+ gem "base64" if RUBY_VERSION >= '3.4'
38
41
  end
data/lib/rouge/cli.rb CHANGED
@@ -5,6 +5,7 @@
5
5
  # to use this module, require 'rouge/cli'.
6
6
 
7
7
  require 'rbconfig'
8
+ require 'uri'
8
9
 
9
10
  module Rouge
10
11
  class FileReader
@@ -348,7 +349,7 @@ module Rouge
348
349
  end
349
350
 
350
351
  private_class_method def self.parse_cgi(str)
351
- pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] }
352
+ pairs = URI.decode_www_form(str).map { |k, v| [k.to_sym, v] }
352
353
  Hash[pairs]
353
354
  end
354
355
  end
@@ -0,0 +1,10 @@
1
+ targetScope = 'subscription' // To create a resource group
2
+
3
+ @description('The Azure region to create the resources in.')
4
+ param location string
5
+
6
+ // Create a resource group
7
+ resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
8
+ name: 'rg-sample'
9
+ location: location
10
+ }
@@ -1,9 +1,6 @@
1
1
  # -*- coding: utf-8 -*- #
2
2
  # frozen_string_literal: true
3
3
 
4
- # stdlib
5
- require 'cgi'
6
-
7
4
  module Rouge
8
5
  module Formatters
9
6
  # Transforms a token stream into HTML output.
@@ -90,14 +90,24 @@ module Rouge
90
90
  disambiguate '*.m' do
91
91
  next ObjectiveC if matches?(/@(end|implementation|protocol|property)\b/)
92
92
  next ObjectiveC if contains?('@"')
93
+
94
+ # Objective-C dereferenced pointers and Mathematica comments are similar.
95
+ # Disambiguate for Mathematica by looking for any amount of whitespace (or no whitespace)
96
+ # followed by "(*" (e.g. `(* comment *)`).
97
+ next Mathematica if matches?(/^\s*\(\*/)
98
+
99
+ # Disambiguate for objc by looking for a deref'd pointer in a statement (e.g. `if (*foo == 0)`).
100
+ # This pattern is less specific than the Mathematica pattern, so its positioned after it.
101
+ next ObjectiveC if matches?(/^\s*(if|while|for|switch|do)\s*\([^)]*\*[^)]*\)/)
93
102
 
94
- next Mathematica if contains?('(*')
95
103
  next Mathematica if contains?(':=')
96
104
 
97
105
  next Mason if matches?(/<%(def|method|text|doc|args|flags|attr|init|once|shared|perl|cleanup|filter)([^>]*)(>)/)
98
106
 
99
107
  next Matlab if matches?(/^\s*?%/)
100
-
108
+ # Matlab cell array creation: data = {
109
+ next Matlab if matches?(/^\s*[a-zA-Z]\w*\s*=\s*\{/)
110
+
101
111
  next Mason if matches? %r!(</?%|<&)!
102
112
  end
103
113
 
data/lib/rouge/lexer.rb CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  # stdlib
5
5
  require 'strscan'
6
- require 'cgi'
7
6
  require 'set'
7
+ require 'uri'
8
8
 
9
9
  module Rouge
10
10
  # @abstract
@@ -52,17 +52,19 @@ module Rouge
52
52
  name, opts = str ? str.split('?', 2) : [nil, '']
53
53
 
54
54
  # parse the options hash from a cgi-style string
55
- opts = CGI.parse(opts || '').map do |k, vals|
56
- val = case vals.size
55
+ cgi_opts = Hash.new { |hash, key| hash[key] = [] }
56
+ URI.decode_www_form(opts || '').each do |k, val|
57
+ cgi_opts[k] << val
58
+ end
59
+ cgi_opts.transform_values! do |vals|
60
+ case vals.size
57
61
  when 0 then true
58
62
  when 1 then vals[0]
59
63
  else vals
60
64
  end
61
-
62
- [ k.to_s, val ]
63
65
  end
64
66
 
65
- opts = default_options.merge(Hash[opts])
67
+ opts = default_options.merge(cgi_opts)
66
68
 
67
69
  lexer_class = case name
68
70
  when 'guess', nil
@@ -5,7 +5,7 @@ module Rouge
5
5
  module Lexers
6
6
  class Ada < RegexLexer
7
7
  tag 'ada'
8
- filenames '*.ada', '*.ads', '*.adb', '*.gpr'
8
+ filenames '*.ada', '*.ads', '*.adb', '*.adc', '*.gpr'
9
9
  mimetypes 'text/x-ada'
10
10
 
11
11
  title 'Ada'
@@ -26,7 +26,7 @@ module Rouge
26
26
  abort abstract accept access aliased all array at begin body
27
27
  case constant declare delay delta digits do else elsif end
28
28
  exception exit for generic goto if in interface is limited
29
- loop new null of others out overriding pragma private
29
+ loop new null of others out overriding parallel pragma private
30
30
  protected raise range record renames requeue return reverse
31
31
  select separate some synchronized tagged task terminate then
32
32
  until use when while with
@@ -143,8 +143,8 @@ module Rouge
143
143
  end
144
144
 
145
145
  # Operators and punctuation characters.
146
- rule %r{[+*/&<=>|]|-|=>|\.\.|\*\*|[:></]=|<<|>>|<>}, Operator
147
- rule %r{[.,:;()]}, Punctuation
146
+ rule %r{[+*/&<=>|]|-|=>|\.\.|\*\*|[:></]=|<<|>>|<>|@}, Operator
147
+ rule %r{[.,:;()\[\]]}, Punctuation
148
148
 
149
149
  rule ID do |m|
150
150
  t = self.class.idents[m[0].downcase]
@@ -0,0 +1,111 @@
1
+ module Rouge
2
+ module Lexers
3
+ class Bicep < Rouge::RegexLexer
4
+ tag 'bicep'
5
+ filenames '*.bicep'
6
+
7
+ title "Bicep"
8
+ desc 'Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources.'
9
+
10
+ def self.keywords
11
+ @keywords ||= Set.new %w(
12
+ as assert existing extends extension false for from func if import in metadata module
13
+ none null output param provider resource targetScope test true type using var void with
14
+ )
15
+ end
16
+
17
+ def self.datatypes
18
+ @datatypes ||= Set.new %w(array bool int object string)
19
+ end
20
+
21
+ def self.functions
22
+ @functions ||= Set.new %w(
23
+ array base64 base64ToJson base64ToString bool cidrHost cidrSubnet concat contains dataUri
24
+ dataUriToString dateTimeAdd dateTimeFromEpoch dateTimeToEpoch deployer deployment empty endsWith
25
+ environment extensionResourceId fail filter first flatten format getSecret groupBy guid indexOf int
26
+ intersection items join json last lastIndexOf length list* listAccountSas listKeys listSecrets loadFileAsBase64
27
+ loadJsonContent loadTextContent loadYamlContent managementGroup managementGroupResourceId map mapValue max min
28
+ newGuid objectKeys padLeft parseCidr pickZones range readEnvironmentVariable reduce reference replace resourceGroup
29
+ resourceId shallowMerge skip sort split startsWith string subscription subscriptionResourceId substring take tenant
30
+ tenantResourceId toLogicalZone toLower toObject toPhysicalZone toUpper trim union uniqueString uri uriComponent
31
+ uriComponentToString utcNow
32
+ )
33
+ end
34
+
35
+ operators = %w(+ - * / % < <= > >= == != =~ !~ && || ! ?? ... .?)
36
+
37
+ punctuations = %w(( ) { } [ ] , : ; = .)
38
+
39
+ state :root do
40
+ mixin :comments
41
+
42
+ # Match strings
43
+ rule %r/'/, Str::Single, :string
44
+
45
+ # Match numbers
46
+ rule %r/\b\d+\b/, Num
47
+
48
+ # Rules for sets of reserved keywords
49
+ rule %r/\b\w+\b/ do |m|
50
+ if self.class.keywords.include? m[0]
51
+ token Keyword
52
+ elsif self.class.datatypes.include? m[0]
53
+ token Keyword::Type
54
+ elsif self.class.functions.include? m[0]
55
+ token Name::Function
56
+ else
57
+ token Name
58
+ end
59
+ end
60
+
61
+ # Match operators
62
+ rule %r/#{operators.map { |o| Regexp.escape(o) }.join('|')}/, Operator
63
+
64
+ # Enter a state when encountering an opening curly bracket
65
+ rule %r/{/, Punctuation::Indicator, :block
66
+
67
+ # Match punctuation
68
+ rule %r/#{punctuations.map { |p| Regexp.escape(p) }.join('|')}/, Punctuation
69
+
70
+ # Match identifiers
71
+ rule %r/[a-zA-Z_]\w*/, Name
72
+
73
+ # Match decorators
74
+ rule %r/@[a-zA-Z_]\w*/, Name::Decorator
75
+
76
+ # Ignore whitespace
77
+ rule %r/\s+/, Text
78
+ end
79
+
80
+ state :comments do
81
+ rule %r(//[^\n\r]+), Comment::Single
82
+ rule %r(/\*.*?\*/)m, Comment::Multiline
83
+ end
84
+
85
+ state :string do
86
+ rule %r/[^'$}]+/, Str::Single
87
+ rule %r/\$(?!\{)/, Str::Single
88
+ rule %r/\$[\{]/, Str::Interpol, :interp
89
+ rule %r/\'/, Str::Single, :pop!
90
+ rule %r/\$+/, Str::Single
91
+ end
92
+
93
+ state :interp do
94
+ rule %r/\}/, Str::Interpol, :pop!
95
+ mixin :root
96
+ end
97
+
98
+ # State for matching code blocks between curly brackets
99
+ state :block do
100
+ # Match property names
101
+ rule %r/\b([a-zA-Z_]\w*)\b(?=\s*:)/, Name::Property
102
+
103
+ # Match closing curly brackets
104
+ rule %r/}/, Punctuation::Indicator, :pop!
105
+
106
+ # Include the root state for nested tokens
107
+ mixin :root
108
+ end
109
+ end
110
+ end
111
+ end
@@ -12,35 +12,40 @@ module Rouge
12
12
  title "C#"
13
13
  desc 'a multi-paradigm language targeting .NET'
14
14
 
15
- # TODO: support more of unicode
16
- id = /@?[_a-z]\w*/i
17
-
18
- #Reserved Identifiers
19
- #Contextual Keywords
20
- #LINQ Query Expressions
21
- keywords = %w(
22
- abstract as base break case catch checked const continue
23
- default delegate do else enum event explicit extern false
24
- finally fixed for foreach goto if implicit in interface
25
- internal is lock new null operator out override params private
26
- protected public readonly ref return sealed sizeof stackalloc
27
- static switch this throw true try typeof unchecked unsafe
28
- virtual void volatile while
29
- add alias async await get global partial remove set value where
30
- yield nameof notnull
31
- ascending by descending equals from group in init into join let
32
- on orderby select unmanaged when and not or with
33
- )
34
-
35
- keywords_type = %w(
36
- bool byte char decimal double dynamic float int long nint nuint
37
- object sbyte short string uint ulong ushort var
38
- )
39
-
40
- cpp_keywords = %w(
41
- if endif else elif define undef line error warning region
42
- endregion pragma nullable
43
- )
15
+ id = /@?[_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}][\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*/
16
+
17
+ # Reserved Identifiers
18
+ # Contextual Keywords
19
+ # LINQ Query Expressions
20
+ def self.keywords
21
+ @keywords ||= %w(
22
+ abstract add alias and as ascending async await base
23
+ break by case catch checked const continue default delegate
24
+ descending do else enum equals event explicit extern false
25
+ finally fixed for foreach from get global goto group
26
+ if implicit in init interface internal into is join
27
+ let lock nameof new notnull null on operator orderby
28
+ out override params partial private protected public readonly
29
+ ref remove return sealed set sizeof stackalloc static
30
+ switch this throw true try typeof unchecked unsafe
31
+ unmanaged value virtual void volatile when where while
32
+ with yield
33
+ )
34
+ end
35
+
36
+ def self.keywords_type
37
+ @keywords_type ||= %w(
38
+ bool byte char decimal double dynamic float int long nint nuint
39
+ object sbyte short string uint ulong ushort var
40
+ )
41
+ end
42
+
43
+ def self.cpp_keywords
44
+ @cpp_keywords ||= %w(
45
+ if endif else elif define undef line error warning region
46
+ endregion pragma nullable
47
+ )
48
+ end
44
49
 
45
50
  state :whitespace do
46
51
  rule %r/\s+/m, Text
@@ -91,10 +96,9 @@ module Rouge
91
96
  )ix, Num
92
97
  rule %r/\b(?:class|record|struct|interface)\b/, Keyword, :class
93
98
  rule %r/\b(?:namespace|using)\b/, Keyword, :namespace
94
- rule %r/^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
95
- Comment::Preproc
96
- rule %r/\b(#{keywords.join('|')})\b/, Keyword
97
- rule %r/\b(#{keywords_type.join('|')})\b/, Keyword::Type
99
+ rule %r/^#[ \t]*(#{CSharp.cpp_keywords.join('|')})\b.*?\n/, Comment::Preproc
100
+ rule %r/\b(#{CSharp.keywords.join('|')})\b/, Keyword
101
+ rule %r/\b(#{CSharp.keywords_type.join('|')})\b/, Keyword::Type
98
102
  rule %r/#{id}(?=\s*[(])/, Name::Function
99
103
  rule id, Name
100
104
  end
@@ -109,7 +113,6 @@ module Rouge
109
113
  rule %r/(?=[(])/, Text, :pop!
110
114
  rule %r/(#{id}|[.])+/, Name::Namespace, :pop!
111
115
  end
112
-
113
116
  end
114
117
  end
115
118
  end
@@ -154,7 +154,7 @@ module Rouge
154
154
  s-resize sans-serif saturation scale-down screen scroll
155
155
  se-resize semi-condensed semi-expanded separate serif show
156
156
  sides silent size slow slower small-caps small-caption smaller
157
- smooth soft soft-light solid space-aroun space-between
157
+ smooth soft soft-light solid space-around space-between
158
158
  space-evenly span spell-out square start static status-bar sticky
159
159
  stretch sub subtract super sw-resize swap symbolic table
160
160
  table-caption table-cell table-column table-column-group
@@ -259,6 +259,7 @@ module Rouge
259
259
  end
260
260
 
261
261
  state :at_rule do
262
+ rule %r/(?:<=|>=|~=|\|=|\^=|\$=|\*=|<|>|=)/, Operator
262
263
  rule %r/{(?=\s*#{identifier}\s*:)/m, Punctuation, :at_stanza
263
264
  rule %r/{/, Punctuation, :at_body
264
265
  rule %r/;/, Punctuation, :pop!
@@ -8,7 +8,7 @@ module Rouge
8
8
  desc "Dockerfile syntax"
9
9
  tag 'docker'
10
10
  aliases 'dockerfile', 'Dockerfile', 'containerfile', 'Containerfile'
11
- filenames 'Dockerfile', '*.Dockerfile', '*.docker', 'Containerfile', '*.Containerfile'
11
+ filenames 'Dockerfile', 'Dockerfile.*', '*.Dockerfile', '*.docker', 'Containerfile', 'Containerfile.*', '*.Containerfile'
12
12
  mimetypes 'text/x-dockerfile-config'
13
13
 
14
14
  KEYWORDS = %w(
@@ -14,8 +14,8 @@ module Rouge
14
14
  identifier = /[\w\-.]+/
15
15
 
16
16
  state :basic do
17
+ rule %r/\s+/, Text::Whitespace
17
18
  rule %r/[;#].*?\n/, Comment
18
- rule %r/\s+/, Text
19
19
  rule %r/\\\n/, Str::Escape
20
20
  end
21
21
 
@@ -23,11 +23,14 @@ module Rouge
23
23
  mixin :basic
24
24
 
25
25
  rule %r/(#{identifier})(\s*)(=)/ do
26
- groups Name::Property, Text, Punctuation
26
+ groups Name::Property, Text::Whitespace, Punctuation
27
27
  push :value
28
28
  end
29
29
 
30
30
  rule %r/\[.*?\]/, Name::Namespace
31
+
32
+ # standalone option, supported by some INI parsers
33
+ rule %r/(.+?)/, Name::Attribute
31
34
  end
32
35
 
33
36
  state :value do
@@ -105,7 +105,26 @@ module Rouge
105
105
  rule %r/\)/, Punctuation, :pop!
106
106
  rule %r/[(,]/, Punctuation
107
107
  rule %r/\s+/, Text
108
- rule %r/"/, Str::Regex, :regex
108
+ rule %r/'/, Str::Regex, :regex_sq
109
+ rule %r/"/, Str::Regex, :regex_dq
110
+ end
111
+
112
+ state :regex_sq do
113
+ rule %r(') do
114
+ token Str::Regex
115
+ goto :regex_end
116
+ end
117
+
118
+ mixin :regex
119
+ end
120
+
121
+ state :regex_dq do
122
+ rule %r(") do
123
+ token Str::Regex
124
+ goto :regex_end
125
+ end
126
+
127
+ mixin :regex
109
128
  end
110
129
 
111
130
  state :regex do
@@ -151,13 +170,15 @@ module Rouge
151
170
  end
152
171
 
153
172
  state :sqs do
173
+ rule %r(\\'), Str::Escape
154
174
  rule %r('), Str::Single, :pop!
155
- rule %r([^']+), Str::Single
175
+ rule %r([^'\\]+), Str::Single
156
176
  end
157
177
 
158
178
  state :dqs do
179
+ rule %r(\\"), Str::Escape
159
180
  rule %r("), Str::Double, :pop!
160
- rule %r([^"]+), Str::Double
181
+ rule %r([^"\\]+), Str::Double
161
182
  end
162
183
  end
163
184
  end
@@ -20,22 +20,24 @@ module Rouge
20
20
  @keywords ||= %w(
21
21
  assert break continue del elif else except exec
22
22
  finally for global if lambda pass print raise
23
- return try while yield as with from import yield
23
+ return try while yield as with from import
24
24
  async await nonlocal
25
25
  )
26
26
  end
27
27
 
28
28
  def self.builtins
29
29
  @builtins ||= %w(
30
- __import__ abs all any apply ascii basestring bin bool buffer
31
- bytearray bytes callable chr classmethod cmp coerce compile
32
- complex delattr dict dir divmod enumerate eval execfile exit
33
- file filter float format frozenset getattr globals hasattr hash hex id
34
- input int intern isinstance issubclass iter len list locals
35
- long map max memoryview min next object oct open ord pow property range
36
- raw_input reduce reload repr reversed round set setattr slice
37
- sorted staticmethod str sum super tuple type unichr unicode
38
- vars xrange zip
30
+ __import__ abs aiter all anext any apply ascii
31
+ basestring bin bool buffer breakpoint bytearray bytes
32
+ callable chr classmethod cmp coerce compile complex
33
+ delattr dict dir divmod enumerate eval exec execfile exit
34
+ file filter float format frozenset getattr globals
35
+ hasattr hash help hex
36
+ id input int intern isinstance issubclass iter len list locals long
37
+ map max memoryview min next object oct open ord pow print property
38
+ range raw_input reduce reload repr reversed round set setattr slice
39
+ sorted staticmethod str sum super tuple type unichr unicode vars
40
+ xrange zip
39
41
  )
40
42
  end
41
43
 
@@ -45,25 +47,26 @@ module Rouge
45
47
 
46
48
  def self.exceptions
47
49
  @exceptions ||= %w(
48
- ArithmeticError AssertionError AttributeError
49
- BaseException BlockingIOError BrokenPipeError BufferError
50
- BytesWarning ChildProcessError ConnectionAbortedError
51
- ConnectionError ConnectionRefusedError ConnectionResetError
52
- DeprecationWarning EOFError EnvironmentError
53
- Exception FileExistsError FileNotFoundError
54
- FloatingPointError FutureWarning GeneratorExit IOError
55
- ImportError ImportWarning IndentationError IndexError
56
- InterruptedError IsADirectoryError KeyError KeyboardInterrupt
57
- LookupError MemoryError ModuleNotFoundError NameError
58
- NotADirectoryError NotImplemented NotImplementedError OSError
59
- OverflowError OverflowWarning PendingDeprecationWarning
60
- ProcessLookupError RecursionError ReferenceError ResourceWarning
61
- RuntimeError RuntimeWarning StandardError StopAsyncIteration
62
- StopIteration SyntaxError SyntaxWarning SystemError SystemExit
63
- TabError TimeoutError TypeError UnboundLocalError UnicodeDecodeError
64
- UnicodeEncodeError UnicodeError UnicodeTranslateError
65
- UnicodeWarning UserWarning ValueError VMSError Warning
66
- WindowsError ZeroDivisionError
50
+ ArithmeticError AssertionError AttributeError BaseException
51
+ BaseExceptionGroup BlockingIOError BrokenPipeError BufferError
52
+ BytesWarning ChildProcessError ConnectionAbortedError ConnectionError
53
+ ConnectionRefusedError ConnectionResetError DeprecationWarning
54
+ EOFError EnvironmentError EncodingWarning Exception ExceptionGroup
55
+ FileExistsError FileNotFoundError FloatingPointError FutureWarning
56
+ GeneratorExit IOError ImportError ImportWarning IndentationError
57
+ IndexError InterruptedError IsADirectoryError
58
+ KeyError KeyboardInterrupt LookupError
59
+ MemoryError ModuleNotFoundError
60
+ NameError NotADirectoryError NotImplemented NotImplementedError
61
+ OSError OverflowError OverflowWarning PendingDeprecationWarning
62
+ PermissionError ProcessLookupError PythonFinalizationError
63
+ RecursionError ReferenceError ResourceWarning RuntimeError RuntimeWarning
64
+ StandardError StopAsyncIteration StopIteration SyntaxError SyntaxWarning
65
+ SystemError SystemExit TabError TimeoutError TypeError
66
+ UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError
67
+ UnicodeTranslateError UnicodeWarning UserWarning ValueError VMSError
68
+ Warning WindowsError
69
+ ZeroDivisionError
67
70
  )
68
71
  end
69
72
 
@@ -127,6 +130,8 @@ module Rouge
127
130
  push :generic_string
128
131
  end
129
132
 
133
+ mixin :soft_keywords
134
+
130
135
  # using negative lookbehind so we don't match property names
131
136
  rule %r/(?<!\.)#{identifier}/ do |m|
132
137
  if self.class.keywords.include? m[0]
@@ -166,6 +171,28 @@ module Rouge
166
171
  rule identifier, Name::Class, :pop!
167
172
  end
168
173
 
174
+ state :soft_keywords do
175
+ rule %r/
176
+ (^[ \t]*)
177
+ (match|case)\b
178
+ (?![ \t]*
179
+ (?:[:,;=^&|@~)\]}] |
180
+ (?:#{Python.keywords.join('|')})\b))
181
+ /x do |m|
182
+ token Text::Whitespace, m[1]
183
+ token Keyword, m[2]
184
+ push :soft_keywords_inner
185
+ end
186
+ end
187
+
188
+ state :soft_keywords_inner do
189
+ rule %r((\s+)([^\n_]*)(_\b)) do |m|
190
+ groups Text::Whitespace, Text, Keyword
191
+ end
192
+
193
+ rule(//) { pop! }
194
+ end
195
+
169
196
  state :raise do
170
197
  rule %r/from\b/, Keyword
171
198
  rule %r/raise\b/, Keyword
@@ -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'
14
+ filenames '*.tf', '*.tfvars'
15
15
 
16
16
  def self.keywords
17
17
  @keywords ||= Set.new %w(
@@ -11,62 +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
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]
70
64
  end
71
65
 
72
66
  state :dq do
@@ -100,15 +94,31 @@ module Rouge
100
94
  end
101
95
 
102
96
  state :array do
103
- mixin :content
97
+ mixin :whitespace
98
+ rule %r/,/, Punctuation
99
+
104
100
  rule %r/\]/, Punctuation, :pop!
101
+
102
+ rule %r//, Token, :value
105
103
  end
106
104
 
107
105
  state :inline do
108
- mixin :content
106
+ rule %r/[ \t]+/, Text::Whitespace
109
107
 
108
+ mixin :key
109
+ rule %r/(=)(\s*)/ do
110
+ groups Punctuation, Text::Whitespace
111
+ push :value
112
+ end
113
+
114
+ rule %r/,/, Punctuation
110
115
  rule %r/\}/, Punctuation, :pop!
111
116
  end
117
+
118
+ state :whitespace do
119
+ rule %r/\s+/, Text
120
+ rule %r/#.*?$/, Comment
121
+ end
112
122
  end
113
123
  end
114
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.5.2"
6
+ "4.6.1"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.2
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
14
13
  email:
@@ -36,6 +35,7 @@ files:
36
35
  - lib/rouge/demos/batchfile
37
36
  - lib/rouge/demos/bbcbasic
38
37
  - lib/rouge/demos/bibtex
38
+ - lib/rouge/demos/bicep
39
39
  - lib/rouge/demos/biml
40
40
  - lib/rouge/demos/bpf
41
41
  - lib/rouge/demos/brainfuck
@@ -284,6 +284,7 @@ files:
284
284
  - lib/rouge/lexers/batchfile.rb
285
285
  - lib/rouge/lexers/bbcbasic.rb
286
286
  - lib/rouge/lexers/bibtex.rb
287
+ - lib/rouge/lexers/bicep.rb
287
288
  - lib/rouge/lexers/biml.rb
288
289
  - lib/rouge/lexers/bpf.rb
289
290
  - lib/rouge/lexers/brainfuck.rb
@@ -542,7 +543,6 @@ metadata:
542
543
  changelog_uri: https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md
543
544
  documentation_uri: https://rouge-ruby.github.io/docs/
544
545
  source_code_uri: https://github.com/rouge-ruby/rouge
545
- post_install_message:
546
546
  rdoc_options: []
547
547
  require_paths:
548
548
  - lib
@@ -557,8 +557,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
557
557
  - !ruby/object:Gem::Version
558
558
  version: '0'
559
559
  requirements: []
560
- rubygems_version: 3.5.3
561
- signing_key:
560
+ rubygems_version: 3.6.7
562
561
  specification_version: 4
563
562
  summary: A pure-ruby colorizer based on pygments
564
563
  test_files: []