rouge 3.10.0 → 3.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge/demos/apex +9 -0
  3. data/lib/rouge/demos/csvs +8 -0
  4. data/lib/rouge/demos/liquid +0 -1
  5. data/lib/rouge/demos/minizinc +23 -0
  6. data/lib/rouge/demos/nesasm +11 -0
  7. data/lib/rouge/demos/q +6 -0
  8. data/lib/rouge/demos/robot_framework +27 -0
  9. data/lib/rouge/demos/slice +10 -0
  10. data/lib/rouge/demos/ttcn3 +6 -0
  11. data/lib/rouge/guessers/disambiguation.rb +5 -0
  12. data/lib/rouge/lexer.rb +3 -0
  13. data/lib/rouge/lexers/apex.rb +126 -0
  14. data/lib/rouge/lexers/bpf.rb +20 -6
  15. data/lib/rouge/lexers/coq.rb +12 -9
  16. data/lib/rouge/lexers/csvs.rb +44 -0
  17. data/lib/rouge/lexers/d.rb +1 -1
  18. data/lib/rouge/lexers/dot.rb +2 -2
  19. data/lib/rouge/lexers/eex.rb +2 -1
  20. data/lib/rouge/lexers/io.rb +2 -2
  21. data/lib/rouge/lexers/json.rb +1 -1
  22. data/lib/rouge/lexers/json_doc.rb +4 -3
  23. data/lib/rouge/lexers/kotlin.rb +21 -28
  24. data/lib/rouge/lexers/liquid.rb +82 -108
  25. data/lib/rouge/lexers/m68k.rb +2 -2
  26. data/lib/rouge/lexers/magik.rb +1 -1
  27. data/lib/rouge/lexers/markdown.rb +7 -1
  28. data/lib/rouge/lexers/mason.rb +0 -5
  29. data/lib/rouge/lexers/minizinc.rb +87 -0
  30. data/lib/rouge/lexers/nesasm.rb +78 -0
  31. data/lib/rouge/lexers/nginx.rb +1 -1
  32. data/lib/rouge/lexers/perl.rb +1 -1
  33. data/lib/rouge/lexers/pony.rb +1 -1
  34. data/lib/rouge/lexers/protobuf.rb +1 -1
  35. data/lib/rouge/lexers/q.rb +2 -1
  36. data/lib/rouge/lexers/robot_framework.rb +249 -0
  37. data/lib/rouge/lexers/scala.rb +3 -3
  38. data/lib/rouge/lexers/shell.rb +5 -3
  39. data/lib/rouge/lexers/sieve.rb +1 -1
  40. data/lib/rouge/lexers/slice.rb +32 -0
  41. data/lib/rouge/lexers/sqf.rb +1 -1
  42. data/lib/rouge/lexers/swift.rb +1 -1
  43. data/lib/rouge/lexers/toml.rb +16 -1
  44. data/lib/rouge/lexers/ttcn3.rb +119 -0
  45. data/lib/rouge/lexers/verilog.rb +1 -1
  46. data/lib/rouge/plugins/redcarpet.rb +7 -1
  47. data/lib/rouge/version.rb +1 -1
  48. metadata +16 -2
@@ -43,7 +43,7 @@ module Rouge
43
43
  rule %r/'#{idrest}[^']/, Str::Symbol
44
44
  rule %r/[^\S\n]+/, Text
45
45
 
46
- rule %r(//.*?\n), Comment::Single
46
+ rule %r(//.*), Comment::Single
47
47
  rule %r(/\*), Comment::Multiline, :comment
48
48
 
49
49
  rule %r/@#{idrest}/, Name::Decorator
@@ -117,7 +117,7 @@ module Rouge
117
117
  rule %r/\s+/, Text
118
118
  rule %r/{/, Operator, :pop!
119
119
  rule %r/\(/, Operator, :pop!
120
- rule %r(//.*?\n), Comment::Single, :pop!
120
+ rule %r(//.*), Comment::Single, :pop!
121
121
  rule %r(#{idrest}|#{op}+|`[^`]+`), Name::Class, :pop!
122
122
  end
123
123
 
@@ -142,7 +142,7 @@ module Rouge
142
142
  pop!
143
143
  end
144
144
 
145
- rule %r(//.*?\n), Comment::Single, :pop!
145
+ rule %r(//.*), Comment::Single, :pop!
146
146
  rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type
147
147
  end
148
148
 
@@ -9,10 +9,12 @@ module Rouge
9
9
 
10
10
  tag 'shell'
11
11
  aliases 'bash', 'zsh', 'ksh', 'sh'
12
- filenames '*.sh', '*.bash', '*.zsh', '*.ksh',
13
- '.bashrc', '.zshrc', '.kshrc', '.profile', 'APKBUILD', 'PKGBUILD'
12
+ filenames '*.sh', '*.bash', '*.zsh', '*.ksh', '.bashrc', '.zshrc',
13
+ '.kshrc', '.profile', 'APKBUILD', 'PKGBUILD', '*.ebuild',
14
+ '*.eclass', '*.exheres-0', '*.exlib'
14
15
 
15
- mimetypes 'application/x-sh', 'application/x-shellscript'
16
+ mimetypes 'application/x-sh', 'application/x-shellscript', 'text/x-sh',
17
+ 'text/x-shellscript'
16
18
 
17
19
  def self.detect?(text)
18
20
  return true if text.shebang?(/(ba|z|k)?sh/)
@@ -58,7 +58,7 @@ module Rouge
58
58
 
59
59
  state :comments_and_whitespace do
60
60
  rule %r/\s+/, Text
61
- rule %r(#.*?\n), Comment::Single
61
+ rule %r(#.*), Comment::Single
62
62
  rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
63
63
  end
64
64
 
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ load_lexer 'c.rb'
7
+
8
+ class Slice < C
9
+ tag 'slice'
10
+ filenames '*.ice'
11
+ mimetypes 'text/slice'
12
+
13
+ title "Slice"
14
+ desc "Specification Language for Ice (doc.zeroc.com)"
15
+
16
+ def self.keywords
17
+ @keywords ||= Set.new %w(
18
+ extends implements enum interface struct class module dictionary
19
+ const optional out throws exception local idempotent sequence
20
+
21
+ Object LocalObject Value
22
+ )
23
+ end
24
+
25
+ def self.keywords_type
26
+ @keywords_type ||= Set.new %w(
27
+ bool string byte long float double int void short
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
@@ -65,7 +65,7 @@ module Rouge
65
65
 
66
66
  # Preprocessor instructions
67
67
  rule %r"/\*.*?\*/"m, Comment::Multiline
68
- rule %r"//.*\n", Comment::Single
68
+ rule %r"//.*", Comment::Single
69
69
  rule %r"#(define|undef|if(n)?def|else|endif|include)", Comment::Preproc
70
70
  rule %r"\\\r?\n", Comment::Preproc
71
71
  rule %r"__(EVAL|EXEC|LINE__|FILE__)", Name::Builtin
@@ -80,7 +80,7 @@ module Rouge
80
80
  rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
81
81
  rule %r{[\d]+(?:_\d+)*}, Num::Integer
82
82
 
83
- rule %r/@#{id}(\([^)]+\))?/, Keyword::Declaration
83
+ rule %r/@#{id}/, Keyword::Declaration
84
84
 
85
85
  rule %r/(private|internal)(\([ ]*)(\w+)([ ]*\))/ do |m|
86
86
  if m[3] == 'set'
@@ -17,6 +17,12 @@ module Rouge
17
17
  rule %r/\s+/, Text
18
18
  rule %r/#.*?$/, Comment
19
19
  rule %r/(true|false)/, Keyword::Constant
20
+
21
+ rule %r/(\S+)(\s*)(=)(\s*)(\{)/ do |m|
22
+ groups Name::Namespace, Text, Operator, Text, Punctuation
23
+ push :inline
24
+ end
25
+
20
26
  rule %r/(?<!=)\s*\[[\S]+\]/, Name::Namespace
21
27
 
22
28
  rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
@@ -33,7 +39,6 @@ module Rouge
33
39
  groups Name::Property, Text, Punctuation
34
40
  push :value
35
41
  end
36
-
37
42
  end
38
43
 
39
44
  state :value do
@@ -63,6 +68,16 @@ module Rouge
63
68
  mixin :content
64
69
  rule %r/\]/, Punctuation, :pop!
65
70
  end
71
+
72
+ state :inline do
73
+ mixin :content
74
+
75
+ rule %r/(#{identifier})(\s*)(=)/ do
76
+ groups Name::Property, Text, Punctuation
77
+ end
78
+
79
+ rule %r/\}/, Punctuation, :pop!
80
+ end
66
81
  end
67
82
  end
68
83
  end
@@ -0,0 +1,119 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class TTCN3 < RegexLexer
7
+ title "TTCN3"
8
+ desc "The TTCN3 programming language (ttcn-3.org)"
9
+
10
+ tag 'ttcn3'
11
+ filenames '*.ttcn', '*.ttcn3'
12
+ mimetypes 'text/x-ttcn3', 'text/x-ttcn'
13
+
14
+ def self.keywords
15
+ @keywords ||= %w(
16
+ module import group type port component signature external
17
+ execute const template function altstep testcase var timer if
18
+ else select case for while do label goto start stop return
19
+ break int2char int2unichar int2bit int2enum int2hex int2oct
20
+ int2str int2float float2int char2int char2oct unichar2int
21
+ unichar2oct bit2int bit2hex bit2oct bit2str hex2int hex2bit
22
+ hex2oct hex2str oct2int oct2bit oct2hex oct2str oct2char
23
+ oct2unichar str2int str2hex str2oct str2float enum2int
24
+ any2unistr lengthof sizeof ispresent ischosen isvalue isbound
25
+ istemplatekind regexp substr replace encvalue decvalue
26
+ encvalue_unichar decvalue_unichar encvalue_o decvalue_o
27
+ get_stringencoding remove_bom rnd hostid send receive
28
+ setverdict
29
+ )
30
+ end
31
+
32
+ def self.reserved
33
+ @reserved ||= %w(
34
+ all alt apply assert at configuration conjunct const control
35
+ delta deterministic disjunct duration fail finished fuzzy from
36
+ history implies inconc inv lazy mod mode notinv now omit
37
+ onentry onexit par pass prev realtime seq setstate static
38
+ stepsize stream timestamp until values wait
39
+ )
40
+ end
41
+
42
+ def self.types
43
+ @types ||= %w(
44
+ anytype address boolean bitstring charstring hexstring octetstring
45
+ component enumerated float integer port record set of union universal
46
+ )
47
+ end
48
+
49
+ # optional comment or whitespace
50
+ ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
51
+ id = /[a-zA-Z_]\w*/
52
+ digit = /\d_+\d|\d/
53
+ bin_digit = /[01]_+[01]|[01]/
54
+ oct_digit = /[0-7]_+[0-7]|[0-7]/
55
+ hex_digit = /\h_+\h|\h/
56
+
57
+ state :statements do
58
+ rule %r/\n+/m, Text
59
+ rule %r/[ \t\r]+/, Text
60
+ rule %r/\\\n/, Text # line continuation
61
+
62
+ rule %r(//(\\.|.)*?$), Comment::Single
63
+ rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
64
+
65
+ rule %r/"/, Str, :string
66
+ rule %r/'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
67
+
68
+ rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/i, Num::Float
69
+ rule %r/'#{bin_digit}+'B/i, Num::Bin
70
+ rule %r/'#{hex_digit}+'H/i, Num::Hex
71
+ rule %r/'#{oct_digit}+'O/i, Num::Oct
72
+ rule %r/#{digit}+/i, Num::Integer
73
+
74
+ rule %r([~!%^&*+:=\|?<>/-]), Operator
75
+ rule %r/[()\[\]{},.;:]/, Punctuation
76
+
77
+ rule %r/(?:true|false|null)\b/, Name::Builtin
78
+
79
+ rule id do |m|
80
+ name = m[0]
81
+ if self.class.keywords.include? name
82
+ token Keyword
83
+ elsif self.class.types.include? name
84
+ token Keyword::Type
85
+ elsif self.class.reserved.include? name
86
+ token Keyword::Reserved
87
+ else
88
+ token Name
89
+ end
90
+ end
91
+ end
92
+
93
+ state :root do
94
+ rule %r/module\b/, Keyword::Declaration, :module
95
+ rule %r/import\b/, Keyword::Namespace, :import
96
+
97
+ mixin :statements
98
+ end
99
+
100
+ state :string do
101
+ rule %r/"/, Str, :pop!
102
+ rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
103
+ rule %r/[^\\"\n]+/, Str
104
+ rule %r/\\\n/, Str
105
+ rule %r/\\/, Str # stray backslash
106
+ end
107
+
108
+ state :module do
109
+ rule %r/\s+/m, Text
110
+ rule id, Name::Class, :pop!
111
+ end
112
+
113
+ state :import do
114
+ rule %r/\s+/m, Text
115
+ rule %r/[\w.]+\*?/, Name::Namespace, :pop!
116
+ end
117
+ end
118
+ end
119
+ end
@@ -100,7 +100,7 @@ module Rouge
100
100
 
101
101
  state :whitespace do
102
102
  rule %r/\n+/m, Text, :bol
103
- rule %r(//(\\.|.)*?\n), Comment::Single, :bol
103
+ rule %r(//(\\.|.)*?$), Comment::Single, :bol
104
104
  mixin :inline_whitespace
105
105
  end
106
106
 
@@ -9,7 +9,13 @@ module Rouge
9
9
  module Plugins
10
10
  module Redcarpet
11
11
  def block_code(code, language)
12
- lexer = Lexer.find_fancy(language, code) || Lexers::PlainText
12
+ lexer =
13
+ begin
14
+ Lexer.find_fancy(language, code)
15
+ rescue Guesser::Ambiguous => e
16
+ e.alternatives.first
17
+ end
18
+ lexer ||= Lexers::PlainText
13
19
 
14
20
  # XXX HACK: Redcarpet strips hard tabs out of code blocks,
15
21
  # so we assume you're not using leading spaces that aren't tabs,
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "3.10.0"
6
+ "3.14.0"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
14
14
  email:
@@ -27,6 +27,7 @@ files:
27
27
  - lib/rouge/demos/actionscript
28
28
  - lib/rouge/demos/ada
29
29
  - lib/rouge/demos/apache
30
+ - lib/rouge/demos/apex
30
31
  - lib/rouge/demos/apiblueprint
31
32
  - lib/rouge/demos/applescript
32
33
  - lib/rouge/demos/armasm
@@ -53,6 +54,7 @@ files:
53
54
  - lib/rouge/demos/crystal
54
55
  - lib/rouge/demos/csharp
55
56
  - lib/rouge/demos/css
57
+ - lib/rouge/demos/csvs
56
58
  - lib/rouge/demos/cuda
57
59
  - lib/rouge/demos/cython
58
60
  - lib/rouge/demos/d
@@ -122,11 +124,13 @@ files:
122
124
  - lib/rouge/demos/mason
123
125
  - lib/rouge/demos/mathematica
124
126
  - lib/rouge/demos/matlab
127
+ - lib/rouge/demos/minizinc
125
128
  - lib/rouge/demos/moonscript
126
129
  - lib/rouge/demos/mosel
127
130
  - lib/rouge/demos/msgtrans
128
131
  - lib/rouge/demos/mxml
129
132
  - lib/rouge/demos/nasm
133
+ - lib/rouge/demos/nesasm
130
134
  - lib/rouge/demos/nginx
131
135
  - lib/rouge/demos/nim
132
136
  - lib/rouge/demos/nix
@@ -153,6 +157,7 @@ files:
153
157
  - lib/rouge/demos/r
154
158
  - lib/rouge/demos/racket
155
159
  - lib/rouge/demos/reasonml
160
+ - lib/rouge/demos/robot_framework
156
161
  - lib/rouge/demos/ruby
157
162
  - lib/rouge/demos/rust
158
163
  - lib/rouge/demos/sas
@@ -163,6 +168,7 @@ files:
163
168
  - lib/rouge/demos/sed
164
169
  - lib/rouge/demos/shell
165
170
  - lib/rouge/demos/sieve
171
+ - lib/rouge/demos/slice
166
172
  - lib/rouge/demos/slim
167
173
  - lib/rouge/demos/smalltalk
168
174
  - lib/rouge/demos/smarty
@@ -178,6 +184,7 @@ files:
178
184
  - lib/rouge/demos/tex
179
185
  - lib/rouge/demos/toml
180
186
  - lib/rouge/demos/tsx
187
+ - lib/rouge/demos/ttcn3
181
188
  - lib/rouge/demos/tulip
182
189
  - lib/rouge/demos/turtle
183
190
  - lib/rouge/demos/twig
@@ -219,6 +226,7 @@ files:
219
226
  - lib/rouge/lexers/ada.rb
220
227
  - lib/rouge/lexers/apache.rb
221
228
  - lib/rouge/lexers/apache/keywords.yml
229
+ - lib/rouge/lexers/apex.rb
222
230
  - lib/rouge/lexers/apiblueprint.rb
223
231
  - lib/rouge/lexers/apple_script.rb
224
232
  - lib/rouge/lexers/armasm.rb
@@ -245,6 +253,7 @@ files:
245
253
  - lib/rouge/lexers/crystal.rb
246
254
  - lib/rouge/lexers/csharp.rb
247
255
  - lib/rouge/lexers/css.rb
256
+ - lib/rouge/lexers/csvs.rb
248
257
  - lib/rouge/lexers/cuda.rb
249
258
  - lib/rouge/lexers/cython.rb
250
259
  - lib/rouge/lexers/d.rb
@@ -318,11 +327,13 @@ files:
318
327
  - lib/rouge/lexers/mathematica/builtins.rb
319
328
  - lib/rouge/lexers/matlab.rb
320
329
  - lib/rouge/lexers/matlab/builtins.yml
330
+ - lib/rouge/lexers/minizinc.rb
321
331
  - lib/rouge/lexers/moonscript.rb
322
332
  - lib/rouge/lexers/mosel.rb
323
333
  - lib/rouge/lexers/msgtrans.rb
324
334
  - lib/rouge/lexers/mxml.rb
325
335
  - lib/rouge/lexers/nasm.rb
336
+ - lib/rouge/lexers/nesasm.rb
326
337
  - lib/rouge/lexers/nginx.rb
327
338
  - lib/rouge/lexers/nim.rb
328
339
  - lib/rouge/lexers/nix.rb
@@ -351,6 +362,7 @@ files:
351
362
  - lib/rouge/lexers/r.rb
352
363
  - lib/rouge/lexers/racket.rb
353
364
  - lib/rouge/lexers/reasonml.rb
365
+ - lib/rouge/lexers/robot_framework.rb
354
366
  - lib/rouge/lexers/ruby.rb
355
367
  - lib/rouge/lexers/rust.rb
356
368
  - lib/rouge/lexers/sas.rb
@@ -362,6 +374,7 @@ files:
362
374
  - lib/rouge/lexers/sed.rb
363
375
  - lib/rouge/lexers/shell.rb
364
376
  - lib/rouge/lexers/sieve.rb
377
+ - lib/rouge/lexers/slice.rb
365
378
  - lib/rouge/lexers/slim.rb
366
379
  - lib/rouge/lexers/smalltalk.rb
367
380
  - lib/rouge/lexers/smarty.rb
@@ -378,6 +391,7 @@ files:
378
391
  - lib/rouge/lexers/tex.rb
379
392
  - lib/rouge/lexers/toml.rb
380
393
  - lib/rouge/lexers/tsx.rb
394
+ - lib/rouge/lexers/ttcn3.rb
381
395
  - lib/rouge/lexers/tulip.rb
382
396
  - lib/rouge/lexers/turtle.rb
383
397
  - lib/rouge/lexers/twig.rb