rouge 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 555fb3207f31723860f17a269418bbaea9dff23c0ae97dc5f27fabd797fc4ad5
4
- data.tar.gz: ad0c9a8de4f66de72f487f8310abda1e763c92816ef2de031a7aea89bcd155c0
3
+ metadata.gz: 239a3d42bfd3954d0e6f97efe4265a99cfa719bc2d0815a3fbfa1d47cb58fa66
4
+ data.tar.gz: 54cccb6161415559baa8a6d8003f9bf9c9c3eb8f241b4c21234c96f1b3d9a148
5
5
  SHA512:
6
- metadata.gz: fcdb09306c5640839523e4ade20a7a272d835f0cd7eec7d2a3b43ae4598d5f0ef50ce2c64e24de31d98e10501f5a8ea53b0e064b51a0e3166756a0669e76b3e9
7
- data.tar.gz: 8c2deba5fc1d897f655642ed01f1817743d249fe1a8dabcc9de873b5203378b63315c5f5fd18c25a479d97aed5e726c9efffb43b1f0c83fbcc6aaf75ce1cf23d
6
+ metadata.gz: 1463511e91aee04d120e090808e232ac5d07435971b3072716046bcc6d43bf5f86c3ef9c1f11b2cfdefded88259951d299f6b476437744ac0861e3dc0516b55f
7
+ data.tar.gz: a4aba9526815bf9d28a6ae7e0d02e3df29b250fa76b53d1c7bca0500cdcc8bd641198db02448e495bea510ac9b3bc1b42fb09ddc3e76dc1d501594074e7602fd
@@ -129,6 +129,7 @@ module Rouge
129
129
 
130
130
  disambiguate '*.cls' do
131
131
  next TeX if matches?(/\A\s*(?:\\|%)/)
132
+ next OpenEdge if matches?(/(no\-undo|BLOCK\-LEVEL|ROUTINE\-LEVEL|&ANALYZE\-SUSPEND)/i)
132
133
  next Apex
133
134
  end
134
135
 
@@ -139,6 +140,12 @@ module Rouge
139
140
 
140
141
  Puppet
141
142
  end
143
+
144
+ disambiguate '*.p' do
145
+ next Prolog if contains?(':-')
146
+ next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./)
147
+ next OpenEdge
148
+ end
142
149
  end
143
150
  end
144
151
  end
@@ -12,16 +12,16 @@ module Rouge
12
12
  mimetypes 'text/x-dart'
13
13
 
14
14
  keywords = %w(
15
- as assert await break case catch continue default do else finally for
16
- if in is new rethrow return super switch this throw try while with yield
15
+ as assert await break case catch continue default do else finally for if
16
+ in is new rethrow return super switch this throw try while when with yield
17
17
  )
18
18
 
19
19
  declarations = %w(
20
- abstract async dynamic const covariant external extends factory final get
21
- implements late native on operator required set static sync typedef var
20
+ abstract base async dynamic const covariant external extends factory final get implements
21
+ inline interface late native on operator required sealed set static sync typedef var
22
22
  )
23
23
 
24
- types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Set String Symbol Type Uri void)
24
+ types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Record Set String Symbol Type Uri void)
25
25
 
26
26
  imports = %w(import deferred export library part\s*of part source)
27
27
 
@@ -53,7 +53,7 @@ module Rouge
53
53
  rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
54
54
  rule %r/(?:#{types.join('|')})\b/, Keyword::Type
55
55
  rule %r/(?:true|false|null)\b/, Keyword::Constant
56
- rule %r/(?:class|interface|mixin)\b/, Keyword::Declaration, :class
56
+ rule %r/(?:class|mixin)\b/, Keyword::Declaration, :class
57
57
  rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
58
58
  rule %r/(\.)(#{id})/ do
59
59
  groups Operator, Name::Attribute
@@ -8,6 +8,7 @@ module Rouge
8
8
  desc "graph description language"
9
9
 
10
10
  tag 'dot'
11
+ aliases 'graphviz'
11
12
  filenames '*.dot'
12
13
  mimetypes 'text/vnd.graphviz'
13
14
 
@@ -190,7 +190,14 @@ module Rouge
190
190
 
191
191
  rule %r/function(?=(\(.*\)))/, Keyword::Declaration # For anonymous functions
192
192
 
193
- rule %r/(#{id})[ \t]*(?=(\(.*\)))/m, Name::Function
193
+ rule %r/(#{id})[ \t]*(?=(\(.*\)))/m do |m|
194
+ if self.class.keywords.include? m[1]
195
+ # "if" in "if (...)" or "switch" in "switch (...)" are recognized as keywords.
196
+ token Keyword
197
+ else
198
+ token Name::Function
199
+ end
200
+ end
194
201
 
195
202
  rule %r/[{}]/, Punctuation, :statement
196
203
 
@@ -14,25 +14,25 @@ module Rouge
14
14
  'text/html+django', 'text/html+jinja'
15
15
 
16
16
  def self.keywords
17
- @@keywords ||= %w(as context do else extends from ignore missing
18
- import include reversed recursive scoped
19
- autoescape endautoescape block endblock call endcall
20
- filter endfilter for endfor if endif macro endmacro
21
- set endset trans endtrans with endwith without)
17
+ @keywords ||= %w(as context do else extends from ignore missing
18
+ import include reversed recursive scoped
19
+ autoescape endautoescape block endblock call endcall
20
+ filter endfilter for endfor if endif macro endmacro
21
+ set endset trans endtrans with endwith without)
22
22
  end
23
23
 
24
24
  def self.tests
25
- @@tests ||= %w(callable defined divisibleby equalto escaped even iterable
26
- lower mapping none number odd sameas sequence string
27
- undefined upper)
25
+ @tests ||= %w(callable defined divisibleby equalto escaped even iterable
26
+ lower mapping none number odd sameas sequence string
27
+ undefined upper)
28
28
  end
29
29
 
30
30
  def self.pseudo_keywords
31
- @@pseudo_keywords ||= %w(true false none True False None)
31
+ @pseudo_keywords ||= %w(true false none True False None)
32
32
  end
33
33
 
34
34
  def self.word_operators
35
- @@word_operators ||= %w(is in and or not)
35
+ @word_operators ||= %w(is in and or not)
36
36
  end
37
37
 
38
38
  state :root do
@@ -8,228 +8,164 @@ module Rouge
8
8
  desc 'Liquid is a templating engine for Ruby (liquidmarkup.org)'
9
9
  tag 'liquid'
10
10
  filenames '*.liquid'
11
+ mimetypes 'text/html+liquid'
11
12
 
12
13
  state :root do
13
14
  rule %r/[^\{]+/, Text
14
15
 
15
16
  rule %r/(\{%-?)(\s*)/ do
16
- groups Punctuation, Text::Whitespace
17
- push :tag_or_block
17
+ groups Comment::Preproc, Text::Whitespace
18
+ push :logic
18
19
  end
19
20
 
20
21
  rule %r/(\{\{-?)(\s*)/ do
21
- groups Punctuation, Text::Whitespace
22
+ groups Comment::Preproc, Text::Whitespace
22
23
  push :output
23
24
  end
24
25
 
25
26
  rule %r/\{/, Text
26
27
  end
27
28
 
28
- state :tag_or_block do
29
+ state :end_logic do
30
+ rule(/(\s*)(-?%\})/) do
31
+ groups Text::Whitespace, Comment::Preproc
32
+ reset_stack
33
+ end
34
+
35
+ rule(/\n\s*/) do
36
+ token Text::Whitespace
37
+ if in_state? :liquid
38
+ pop! until state? :liquid
39
+ end
40
+ end
41
+
42
+ mixin :whitespace
43
+ end
44
+
45
+ state :end_output do
46
+ rule(/(\s*)(-?\}\})/) do
47
+ groups Text::Whitespace, Comment::Preproc
48
+ reset_stack
49
+ end
50
+ end
51
+
52
+ state :liquid do
53
+ mixin :end_logic
54
+ mixin :logic
55
+ end
56
+
57
+ state :logic do
58
+ rule %r/(liquid)\b/, Name::Tag, :liquid
59
+
29
60
  # builtin logic blocks
30
- rule %r/(if|elsif|unless|case)\b/, Keyword::Reserved, :condition
31
- rule %r/(when)\b/, Keyword::Reserved, :when
61
+ rule %r/(if|elsif|unless|case)\b/, Name::Tag, :condition
62
+ rule %r/(when)\b/, Name::Tag, :value
63
+ rule %r/(else|ifchanged|end\w+)\b/, Name::Tag, :end_logic
64
+ rule %r/(break|continue)\b/, Keyword::Reserved, :end_logic
32
65
 
33
- rule %r/(else)(\s*)(-?%\})/ do
34
- groups Keyword::Reserved, Text::Whitespace, Punctuation
35
- pop!
66
+ # builtin iteration blocks
67
+ rule %r/(for|tablerow)(\s+)(\S+)(\s+)(in)(\s+)/ do
68
+ groups Name::Tag, Text::Whitespace, Name::Variable, Text::Whitespace,
69
+ Name::Tag, Text::Whitespace
70
+ push :iteration_args
36
71
  end
37
72
 
38
73
  # other builtin blocks
39
- rule %r/(capture|(?:in|de)crement)(\s+)([^\s%]+)(\s*)(-?%\})/ do
40
- groups Name::Tag, Text::Whitespace, Name::Variable, Text::Whitespace, Punctuation
41
- pop!
74
+ rule %r/(capture|(?:in|de)crement)(\s+)([a-zA-Z_](?:\w|-(?!%))*)/ do
75
+ groups Name::Tag, Text::Whitespace, Name::Variable
76
+ push :end_logic
42
77
  end
43
78
 
44
79
  rule %r/(comment)(\s*)(-?%\})/ do
45
- groups Name::Tag, Text::Whitespace, Punctuation
80
+ groups Name::Tag, Text::Whitespace, Comment::Preproc
46
81
  push :comment
47
82
  end
48
83
 
49
84
  rule %r/(raw)(\s*)(-?%\})/ do
50
- groups Name::Tag, Text::Whitespace, Punctuation
85
+ groups Name::Tag, Text::Whitespace, Comment::Preproc
51
86
  push :raw
52
87
  end
53
88
 
54
- # end of block
55
- rule %r/(end(?:if|unless|case))(\s*)(-?%\})/ do
56
- groups Keyword::Reserved, Text::Whitespace, Punctuation
57
- pop!
58
- end
59
-
60
- rule %r/(end(?:[^\s%]+))(\s*)(-?%\})/ do
61
- groups Name::Tag, Text::Whitespace, Punctuation
62
- pop!
63
- end
64
-
65
89
  # builtin tags
66
90
  rule %r/(assign|echo)\b/, Name::Tag, :assign
67
- rule %r/(include|render)\b/, Name::Tag, :include
68
91
 
69
- rule %r/(cycle)(\s+)(?:([^\s:]*)(\s*)(:))?(\s*)/ do |m|
92
+ rule %r/(include|render)(\s+)([\/\w-]+(?:\.[\w-]+)+\b)?/ do
93
+ groups Name::Tag, Text::Whitespace, Text
94
+ push :include
95
+ end
96
+
97
+ rule %r/(cycle)(\s+)(?:([\w-]+|'[^']*'|"[^"]*")(\s*)(:))?(\s*)/ do |m|
70
98
  token_class = case m[3]
71
99
  when %r/'[^']*'/ then Str::Single
72
100
  when %r/"[^"]*"/ then Str::Double
73
101
  else
74
102
  Name::Attribute
75
103
  end
76
-
77
104
  groups Name::Tag, Text::Whitespace, token_class,
78
105
  Text::Whitespace, Punctuation, Text::Whitespace
79
-
80
- push :variable_tag_markup
106
+ push :tag_args
81
107
  end
82
108
 
83
- # iteration
84
- rule %r/
85
- (for|tablerow)(\s+)
86
- ([\w-]+)(\s+)
87
- (in)(\s+)
88
- (
89
- (?: [^\s%,\|'"] | (?:"[^"]*"|'[^']*') )+
90
- )(\s*)
91
- /x do |m|
92
- groups Name::Tag, Text::Whitespace, Name::Variable, Text::Whitespace,
93
- Name::Tag, Text::Whitespace
94
-
95
- token_class = case m[7]
96
- when %r/'[^']*'/ then Str::Single
97
- when %r/"[^"]*"/ then Str::Double
98
- else
99
- Name::Variable
100
- end
101
- token token_class, m[7]
102
- token Text::Whitespace, m[8]
103
- push :tag_markup
104
- end
109
+ # custom tags or blocks
110
+ rule %r/(\w+)\b/, Name::Tag, :block_args
105
111
 
106
- # other tags or blocks
107
- rule %r/([^\s%]+)(\s*)/ do
108
- groups Name::Tag, Text::Whitespace
109
- push :tag_markup
110
- end
112
+ mixin :end_logic
111
113
  end
112
114
 
113
115
  state :output do
114
- rule %r/(\|)(\s*)([a-zA-Z_][^\s}\|:]*)/ do
115
- groups Punctuation, Text::Whitespace, Name::Function
116
+ rule %r/(\|)(\s*)/ do
117
+ groups Punctuation, Text::Whitespace
116
118
  push :filters
119
+ push :filter
117
120
  end
118
121
 
119
- mixin :end_of_tag
120
- mixin :generic
121
- end
122
-
123
- state :filters do
124
- rule %r/(\|)(\s*)([a-zA-Z_][^\s%}\|:]*)/ do
125
- groups Punctuation, Text::Whitespace, Name::Function
126
- end
127
-
128
- mixin :end_of_tag
129
- mixin :end_of_block
130
- mixin :variable_param_markup
122
+ mixin :end_output
123
+ mixin :static
124
+ mixin :variable
131
125
  end
132
126
 
133
127
  state :condition do
134
128
  rule %r/([=!]=|[<>]=?)/, Operator
135
129
  rule %r/(and|or|contains)\b/, Operator::Word
136
130
 
137
- mixin :end_of_block
138
- mixin :generic
139
- end
140
-
141
- state :when do
142
- mixin :end_of_block
143
- mixin :generic
144
- end
145
-
146
- state :end_of_tag do
147
- rule(/-?\}\}/) { token Punctuation; reset_stack }
131
+ mixin :value
148
132
  end
149
133
 
150
- state :end_of_block do
151
- rule(/-?%\}/) { token Punctuation; reset_stack }
152
- end
153
-
154
- # states for unknown markup
155
- state :param_markup do
156
- mixin :whitespace
157
- mixin :keyword
158
- mixin :string
159
- mixin :number
160
-
161
- rule %r/([^\s=:]+)(\s*)(=|:)/ do
162
- groups Name::Attribute, Text::Whitespace, Operator
163
- end
164
-
165
- rule %r/[,:]/, Punctuation
166
- end
167
-
168
- state :default_param_markup do
169
- mixin :param_markup
170
-
171
- rule %r/\S+/, Text
172
- end
173
-
174
- state :variable_param_markup do
175
- mixin :param_markup
134
+ state :value do
135
+ mixin :end_logic
136
+ mixin :static
176
137
  mixin :variable
177
-
178
- rule %r/\S+/, Text
179
- end
180
-
181
- state :tag_markup do
182
- rule %r/(reversed)\b/, Name::Attribute
183
-
184
- mixin :end_of_block
185
- mixin :default_param_markup
186
- end
187
-
188
- state :variable_tag_markup do
189
- mixin :end_of_block
190
- mixin :variable_param_markup
191
138
  end
192
139
 
193
- # states for different values types
194
- state :keyword do
195
- rule %r/(false|true|nil)\b/, Keyword::Constant
196
- end
140
+ state :iteration_args do
141
+ rule %r/(reversed|continue)\b/, Name::Attribute
142
+ rule %r/\(/, Punctuation, :range
197
143
 
198
- state :variable do
199
- rule %r/(empty|blank|forloop\.[^\s%}\|:]+)\b/, Name::Builtin
200
- rule %r/\.(?=\w)|\[|\]/, Punctuation
201
- rule %r/(first|last|size)\b/, Name::Function
202
- rule %r/[a-zA-Z_][\w-]*\??/, Name::Variable
144
+ mixin :tag_args
203
145
  end
204
146
 
205
- state :string do
206
- rule %r/'[^']*'/, Str::Single
207
- rule %r/"[^"]*"/, Str::Double
208
- end
147
+ state :block_args do
148
+ rule %r/(\{\{-?)/, Comment::Preproc, :output_embed
209
149
 
210
- state :number do
211
- rule %r/-/, Operator
212
- rule %r/\d+\.\d+/, Num::Float
213
- rule %r/\d+/, Num::Integer
214
- end
150
+ rule %r/(\|)(\s*)/ do
151
+ groups Punctuation, Text::Whitespace
152
+ push :filters
153
+ push :filter
154
+ end
215
155
 
216
- state :generic do
217
- mixin :whitespace
218
- mixin :keyword
219
- mixin :string
220
- mixin :number
221
- mixin :variable
156
+ mixin :tag_args
222
157
  end
223
158
 
224
- state :whitespace do
225
- rule %r/[ \t]+/, Text::Whitespace
159
+ state :tag_args do
160
+ mixin :end_logic
161
+ mixin :args
226
162
  end
227
163
 
228
164
  state :comment do
229
165
  rule %r/[^\{]+/, Comment
230
166
 
231
167
  rule %r/(\{%-?)(\s*)(endcomment)(\s*)(-?%\})/ do
232
- groups Punctuation, Text::Whitespace, Name::Tag, Text::Whitespace, Punctuation
168
+ groups Comment::Preproc, Text::Whitespace, Name::Tag, Text::Whitespace, Comment::Preproc
233
169
  reset_stack
234
170
  end
235
171
 
@@ -240,7 +176,7 @@ module Rouge
240
176
  rule %r/[^\{]+/, Text
241
177
 
242
178
  rule %r/(\{%-?)(\s*)(endraw)(\s*)(-?%\})/ do
243
- groups Punctuation, Text::Whitespace, Name::Tag, Text::Whitespace, Punctuation
179
+ groups Comment::Preproc, Text::Whitespace, Name::Tag, Text::Whitespace, Comment::Preproc
244
180
  reset_stack
245
181
  end
246
182
 
@@ -249,36 +185,100 @@ module Rouge
249
185
 
250
186
  state :assign do
251
187
  rule %r/=/, Operator
188
+ rule %r/\(/, Punctuation, :range
252
189
 
253
- rule %r/(\|)(\s*)([a-zA-Z_][^\s%\|:]*)/ do
254
- groups Punctuation, Text::Whitespace, Name::Function
190
+ rule %r/(\|)(\s*)/ do
191
+ groups Punctuation, Text::Whitespace
255
192
  push :filters
193
+ push :filter
256
194
  end
257
195
 
258
- mixin :end_of_block
259
- mixin :generic
196
+ mixin :value
260
197
  end
261
198
 
262
199
  state :include do
263
- rule %r/(\{\{-?)(\s*)/ do
200
+ rule %r/(\{\{-?)/, Comment::Preproc, :output_embed
201
+ rule %r/(with|for|as)\b/, Keyword::Reserved
202
+
203
+ mixin :tag_args
204
+ end
205
+
206
+ state :output_embed do
207
+ rule %r/(\|)(\s*)([a-zA-Z_](?:\w|-(?!}))*)/ do
208
+ groups Punctuation, Text::Whitespace, Name::Function
209
+ end
210
+
211
+ rule %r/-?\}\}/, Comment::Preproc, :pop!
212
+
213
+ mixin :args
214
+ end
215
+
216
+ state :range do
217
+ rule %r/\.\./, Punctuation
218
+ rule %r/\)/, Punctuation, :pop!
219
+
220
+ mixin :whitespace
221
+ mixin :number
222
+ mixin :variable
223
+ end
224
+
225
+ state :filters do
226
+ rule %r/(\|)(\s*)/ do
264
227
  groups Punctuation, Text::Whitespace
265
- push :output_embed
228
+ push :filter
266
229
  end
267
230
 
268
- rule %r/(with|for)\b/, Name::Tag
269
- rule %r/[\/\w-]+(\.[\w-]+)+\b/, Text
231
+ mixin :end_logic
232
+ mixin :end_output
233
+ mixin :args
234
+ end
270
235
 
271
- mixin :variable_tag_markup
236
+ state :filter do
237
+ rule %r/[a-zA-Z_](?:\w|-(?![%}]))*/, Name::Function, :pop!
238
+
239
+ mixin :whitespace
272
240
  end
273
241
 
274
- state :output_embed do
275
- rule %r/(\|)(\s*)([a-zA-Z_][^\s}\|:]*)/ do
276
- groups Punctuation, Text::Whitespace, Name::Function
242
+ state :args do
243
+ mixin :static
244
+
245
+ rule %r/([a-zA-Z_][\w-]*)(\s*)(=|:)/ do
246
+ groups Name::Attribute, Text::Whitespace, Operator
277
247
  end
278
248
 
279
- rule %r/-?\}\}/, Punctuation, :pop!
249
+ mixin :variable
250
+ end
280
251
 
281
- mixin :variable_param_markup
252
+ state :static do
253
+ rule %r/(false|true|nil)\b/, Keyword::Constant
254
+ rule %r/'[^']*'/, Str::Single
255
+ rule %r/"[^"]*"/, Str::Double
256
+ rule %r/[,:]/, Punctuation
257
+
258
+ mixin :whitespace
259
+ mixin :number
260
+ end
261
+
262
+ state :whitespace do
263
+ rule %r/\s+/, Text::Whitespace
264
+ rule %r/#.*?(?=$|-?[}%]})/, Comment
265
+ end
266
+
267
+ state :number do
268
+ rule %r/-/, Operator
269
+ rule %r/\d+\.\d+/, Num::Float
270
+ rule %r/\d+/, Num::Integer
271
+ end
272
+
273
+ state :variable do
274
+ rule %r/(\.)(\s*)(first|last|size)\b(?![?!\/])/ do
275
+ groups Punctuation, Text::Whitespace, Name::Function
276
+ end
277
+
278
+ rule %r/\.(?= *\w)|\[|\]/, Punctuation
279
+ rule %r/(empty|blank|(for|tablerow)loop\.(parentloop\.)*\w+)\b(?![?!\/])/, Name::Builtin
280
+ rule %r/[a-zA-Z_][\w-]*\b-?(?![?!\/])/, Name::Variable
281
+ rule %r/\S+/, Text
282
282
  end
283
283
  end
284
284
  end
@@ -13,10 +13,6 @@ module Rouge
13
13
 
14
14
  mimetypes 'text/x-mosel'
15
15
 
16
- def self.detect?(text)
17
- return true if text =~ /^\s*(model|package)\s+/
18
- end
19
-
20
16
  id = /[a-zA-Z_][a-zA-Z0-9_]*/
21
17
 
22
18
  ############################################################################################################################