rouge 4.6.0 → 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: 7a7fb3b7ebd844675016c5515295713f72c36ded464d0a9bdb64e5929ab40f18
4
- data.tar.gz: 19d434e8b8fa8ad3c12483ad03fe74b09ca46b76f7d2ba0b8867d7e0303bfc85
3
+ metadata.gz: 83340a3ee45685522d7b91daf3d85c87721430d3606ab761353099941f272f4e
4
+ data.tar.gz: 112aa358b29944ddbba5d837ae32bcd833a7c5c9d9b4100a952a265dc9c5459c
5
5
  SHA512:
6
- metadata.gz: fc2d202d4258acaffdaf0bee314049bf55876ee89384ef5e8d5625df1994f4789c893b2119721c1e3f71afed4040e3988774fa9e71ae8f7996fd90cff158ae22
7
- data.tar.gz: f93bbd478d426253369e29b3b2a7b806bc68a6397e78dcf73061ca0c5295ee800691aee291cef9ff7caeca610b98292c1b18bc67f54b214660b36edbb187b565
6
+ metadata.gz: d266d81096d98c4cbd51d0cc79edef8887a40465e749bfc51d32ae0a493b0be23e090234336a8accfdfe45d48e4a25d4bd50391f369d8901c5a1ec946071d604
7
+ data.tar.gz: 011ff0045c3de53ca6e1647651d3fe8cd722a57656d3d08ca4559a1dfb40b3940162c6502ff71ead6ebe0ff95a60e8924d2d50ee5c0b144bff344a6392563f7c
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
@@ -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.
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
@@ -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!
@@ -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
@@ -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,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.6.1"
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.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson