rouge 3.28.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -11
  3. data/lib/rouge/cli.rb +23 -20
  4. data/lib/rouge/demos/brainfuck +1 -1
  5. data/lib/rouge/demos/brightscript +1 -1
  6. data/lib/rouge/demos/bsl +1 -1
  7. data/lib/rouge/demos/cfscript +1 -1
  8. data/lib/rouge/demos/coq +1 -1
  9. data/lib/rouge/demos/csvs +1 -1
  10. data/lib/rouge/demos/datastudio +0 -1
  11. data/lib/rouge/demos/ecl +0 -1
  12. data/lib/rouge/demos/erlang +1 -1
  13. data/lib/rouge/demos/fsharp +1 -1
  14. data/lib/rouge/demos/glsl +1 -1
  15. data/lib/rouge/demos/haxe +0 -1
  16. data/lib/rouge/demos/idris +13 -0
  17. data/lib/rouge/demos/isabelle +16 -0
  18. data/lib/rouge/demos/lean +8 -0
  19. data/lib/rouge/demos/meson +10 -0
  20. data/lib/rouge/demos/nesasm +1 -1
  21. data/lib/rouge/demos/nial +35 -0
  22. data/lib/rouge/demos/opentype_feature_file +0 -1
  23. data/lib/rouge/demos/plsql +2 -0
  24. data/lib/rouge/demos/rml +33 -0
  25. data/lib/rouge/demos/smarty +0 -1
  26. data/lib/rouge/demos/syzlang +15 -0
  27. data/lib/rouge/demos/syzprog +8 -0
  28. data/lib/rouge/formatters/html_inline.rb +0 -1
  29. data/lib/rouge/guessers/disambiguation.rb +7 -0
  30. data/lib/rouge/lexer.rb +2 -2
  31. data/lib/rouge/lexers/apache/keywords.rb +1 -1
  32. data/lib/rouge/lexers/apple_script.rb +1 -1
  33. data/lib/rouge/lexers/cpp.rb +1 -0
  34. data/lib/rouge/lexers/dart.rb +2 -1
  35. data/lib/rouge/lexers/diff.rb +14 -4
  36. data/lib/rouge/lexers/docker.rb +4 -0
  37. data/lib/rouge/lexers/eiffel.rb +0 -1
  38. data/lib/rouge/lexers/gherkin/keywords.rb +1 -1
  39. data/lib/rouge/lexers/groovy.rb +1 -1
  40. data/lib/rouge/lexers/handlebars.rb +1 -1
  41. data/lib/rouge/lexers/haxe.rb +30 -11
  42. data/lib/rouge/lexers/http.rb +1 -1
  43. data/lib/rouge/lexers/hylang.rb +0 -1
  44. data/lib/rouge/lexers/idris.rb +210 -0
  45. data/lib/rouge/lexers/isabelle.rb +251 -0
  46. data/lib/rouge/lexers/javascript.rb +1 -1
  47. data/lib/rouge/lexers/jsx.rb +0 -1
  48. data/lib/rouge/lexers/lasso/keywords.rb +1 -1
  49. data/lib/rouge/lexers/lean.rb +164 -0
  50. data/lib/rouge/lexers/llvm/keywords.rb +1 -1
  51. data/lib/rouge/lexers/lua/keywords.rb +1 -1
  52. data/lib/rouge/lexers/make.rb +25 -16
  53. data/lib/rouge/lexers/mathematica/keywords.rb +1 -1
  54. data/lib/rouge/lexers/matlab/keywords.rb +1 -1
  55. data/lib/rouge/lexers/matlab.rb +3 -2
  56. data/lib/rouge/lexers/meson.rb +159 -0
  57. data/lib/rouge/lexers/nial.rb +166 -0
  58. data/lib/rouge/lexers/ocl.rb +0 -1
  59. data/lib/rouge/lexers/pascal.rb +2 -1
  60. data/lib/rouge/lexers/php/keywords.rb +1 -1
  61. data/lib/rouge/lexers/php.rb +7 -5
  62. data/lib/rouge/lexers/plsql.rb +578 -0
  63. data/lib/rouge/lexers/praat.rb +20 -2
  64. data/lib/rouge/lexers/prometheus.rb +0 -1
  65. data/lib/rouge/lexers/python.rb +3 -1
  66. data/lib/rouge/lexers/q.rb +0 -1
  67. data/lib/rouge/lexers/rml.rb +142 -0
  68. data/lib/rouge/lexers/sqf/keywords.rb +1 -1
  69. data/lib/rouge/lexers/supercollider.rb +0 -1
  70. data/lib/rouge/lexers/syzlang.rb +317 -0
  71. data/lib/rouge/lexers/syzprog.rb +122 -0
  72. data/lib/rouge/lexers/tap.rb +0 -1
  73. data/lib/rouge/lexers/toml.rb +12 -7
  74. data/lib/rouge/lexers/tsx.rb +7 -1
  75. data/lib/rouge/lexers/tulip.rb +0 -1
  76. data/lib/rouge/lexers/typescript/common.rb +4 -1
  77. data/lib/rouge/lexers/viml/keywords.rb +1 -1
  78. data/lib/rouge/version.rb +1 -1
  79. data/rouge.gemspec +1 -1
  80. metadata +22 -6
  81. data/lib/rouge/demos/solidity +0 -13
  82. data/lib/rouge/lexers/solidity.rb +0 -185
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a74c520254d1312e4a5343103e3d83b48c967025a77a01701c42820a5eb3c708
4
- data.tar.gz: 2fb290b030a0d60910973c53398c0dd4b127d17c1b489c88105f0bddb3689f6e
3
+ metadata.gz: 9229545bdc0804f0a7f0fea6a4fd1b94dbe8d022d0d29c1ffa254c09f42003d1
4
+ data.tar.gz: cf12e8de0f2d03d37ed6f1380a5deb04ad385d8628b4f2ed7c1921b16161636f
5
5
  SHA512:
6
- metadata.gz: f499d28b76cd95fa2182d64809c4b6828c735a95c05c1b9af858ac6c1d0d17755fdafa90ae93f9d7fd27bd826fb4055cb8d3985d94b17172018ef408a397d8cf
7
- data.tar.gz: 7fcd54cac21c2fb1b1cdc0825691ce812f42bc5d18cace205b281aaf87e7d8a75ee2dca544e92b9b193084605811f74151b00c51237850952cb22d4e4dde5db9
6
+ metadata.gz: 31f64a3f386d01829f9a2d2e9711ad40c3c48fbf122dc66b0e9519d4c02676cf530879c388e280efd996d6a57ec3497f5faa54423d081af02450348037c58712
7
+ data.tar.gz: fad76c2d5d770fb172e09a2614e37ff78d362b81dfb73d50ce5c25de04f07c93aabae357e4a1a5b6b47be3792edf146e1299c1ec78204d55e998dd54c169f307
data/Gemfile CHANGED
@@ -10,16 +10,14 @@ gem 'minitest', '>= 5.0'
10
10
  gem 'minitest-power_assert'
11
11
  gem 'power_assert', '~> 1.2'
12
12
 
13
- gem 'parallel', '~> 1.13.0' if RUBY_VERSION < '2.2.0'
14
- gem 'rubocop', '~> 0.49.1'
13
+ gem 'rubocop', '~> 1.0', '<= 1.11'
14
+ gem 'rubocop-performance'
15
15
 
16
16
  # don't try to install redcarpet under jruby
17
- gem 'redcarpet', :platforms => :ruby
17
+ gem 'redcarpet', platforms: :ruby
18
18
 
19
19
  # Profiling
20
- if RUBY_VERSION >= '2.3.0'
21
- gem 'memory_profiler', :require => false
22
- end
20
+ gem 'memory_profiler', require: false
23
21
 
24
22
  # Needed for a Rake task
25
23
  gem 'git'
@@ -32,11 +30,7 @@ group :development do
32
30
  gem 'github-markup'
33
31
 
34
32
  # for visual tests
35
- if RUBY_VERSION < '2.2.0'
36
- gem 'sinatra', '~> 1.4.8'
37
- else
38
- gem 'sinatra'
39
- end
33
+ gem 'sinatra'
40
34
 
41
35
  # Ruby 3 no longer ships with a web server
42
36
  gem 'puma' if RUBY_VERSION >= '3'
data/lib/rouge/cli.rb CHANGED
@@ -174,35 +174,38 @@ module Rouge
174
174
  yield %[usage: rougify highlight <filename> [options...]]
175
175
  yield %[ rougify highlight [options...]]
176
176
  yield %[]
177
- yield %[--input-file|-i <filename> specify a file to read, or - to use stdin]
177
+ yield %[--input-file|-i <filename> specify a file to read, or - to use stdin]
178
178
  yield %[]
179
- yield %[--lexer|-l <lexer> specify the lexer to use.]
180
- yield %[ If not provided, rougify will try to guess]
181
- yield %[ based on --mimetype, the filename, and the]
182
- yield %[ file contents.]
179
+ yield %[--lexer|-l <lexer> specify the lexer to use.]
180
+ yield %[ If not provided, rougify will try to guess]
181
+ yield %[ based on --mimetype, the filename, and the]
182
+ yield %[ file contents.]
183
183
  yield %[]
184
- yield %[--formatter|-f <opts> specify the output formatter to use.]
185
- yield %[ If not provided, rougify will default to]
186
- yield %[ terminal256.]
184
+ yield %[--formatter-preset|-f <opts> specify the output formatter to use.]
185
+ yield %[ If not provided, rougify will default to]
186
+ yield %[ terminal256. options are: terminal256,]
187
+ yield %[ terminal-truecolor, html, html-pygments,]
188
+ yield %[ html-inline, html-line-table, html-table,]
189
+ yield %[ null/raw/tokens, or tex.]
187
190
  yield %[]
188
- yield %[--theme|-t <theme> specify the theme to use for highlighting]
189
- yield %[ the file. (only applies to some formatters)]
191
+ yield %[--theme|-t <theme> specify the theme to use for highlighting]
192
+ yield %[ the file. (only applies to some formatters)]
190
193
  yield %[]
191
- yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
194
+ yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
192
195
  yield %[]
193
- yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
194
- yield %[ (opt1=val1&opt2=val2)]
196
+ yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
197
+ yield %[ (opt1=val1&opt2=val2)]
195
198
  yield %[]
196
- yield %[--formatter-opts|-F <opts> specify formatter options in CGI format]
197
- yield %[ (opt1=val1&opt2=val2)]
199
+ yield %[--formatter-opts|-F <opts> specify formatter options in CGI format]
200
+ yield %[ (opt1=val1&opt2=val2)]
198
201
  yield %[]
199
- yield %[--require|-r <filename> require a filename or library before]
200
- yield %[ highlighting]
202
+ yield %[--require|-r <filename> require a filename or library before]
203
+ yield %[ highlighting]
201
204
  yield %[]
202
- yield %[--escape allow the use of escapes between <! and !>]
205
+ yield %[--escape allow the use of escapes between <! and !>]
203
206
  yield %[]
204
- yield %[--escape-with <l> <r> allow the use of escapes between custom]
205
- yield %[ delimiters. implies --escape]
207
+ yield %[--escape-with <l> <r> allow the use of escapes between custom]
208
+ yield %[ delimiters. implies --escape]
206
209
  end
207
210
 
208
211
  # There is no consistent way to do this, but this is used elsewhere,
@@ -2,4 +2,4 @@
2
2
  This is a sample
3
3
  comment.
4
4
  ]
5
- .[>+<-]>,
5
+ .[>+<-]>,
@@ -3,4 +3,4 @@ function main(args as dynamic) as void
3
3
  'Create a scene and load /components/helloworld.xml'
4
4
  scene = screen.CreateScene("HelloWorld")
5
5
  screen.show()
6
- end function
6
+ end function
data/lib/rouge/demos/bsl CHANGED
@@ -4,4 +4,4 @@
4
4
  Сообщить("Привет мир");
5
5
  КонецПроцедуры
6
6
 
7
- #КонецОбласти
7
+ #КонецОбласти
@@ -15,4 +15,4 @@ component accessors="true" {
15
15
 
16
16
  return foo;
17
17
  }
18
- }
18
+ }
data/lib/rouge/demos/coq CHANGED
@@ -10,4 +10,4 @@ Section with_T.
10
10
  end.
11
11
  End with_T.
12
12
 
13
- Definition a_string := "hello \" world".
13
+ Definition a_string := "hello \" world".
data/lib/rouge/demos/csvs CHANGED
@@ -5,4 +5,4 @@ Transaction_Date: xDate
5
5
  Transaction_ID: notEmpty
6
6
  Originator_Name: notEmpty
7
7
  Originator_Address: any("yes","no")
8
- Originator_Country: notEmpty
8
+ Originator_Country: notEmpty
@@ -18,4 +18,3 @@ select * from TABLE1 where COL1 like %VAR1%; //utiliser la variable VAR1 dans un
18
18
 
19
19
  select * from TEST_TABLE; //exécution d'une requête Select pour ramener des valeurs
20
20
  Affect_LastColumns("TEST1"); //création du paramètre TEST1
21
-
data/lib/rouge/demos/ecl CHANGED
@@ -15,4 +15,3 @@ somePeople := allPeople(LastName = 'Smith');
15
15
 
16
16
  // Outputs ---
17
17
  somePeople;
18
-
@@ -4,4 +4,4 @@
4
4
 
5
5
  %% Compute rectangle and circle area.
6
6
  area({rectangle, Width, Ht}) -> Width * Ht;
7
- area({circle, R}) -> 3.14159 * R * R.
7
+ area({circle, R}) -> 3.14159 * R * R.
@@ -9,4 +9,4 @@ let rec existsLeaf test tree =
9
9
  || existsLeaf test right
10
10
 
11
11
  let hasEvenLeaf tree =
12
- existsLeaf (fun n -> n % 2 = 0) tree
12
+ existsLeaf (fun n -> n % 2 = 0) tree
data/lib/rouge/demos/glsl CHANGED
@@ -11,4 +11,4 @@ void main()
11
11
  {
12
12
  vertexColor = color;
13
13
  gl_Position = vec4(position, 0.0, 1.0);
14
- }
14
+ }
data/lib/rouge/demos/haxe CHANGED
@@ -2,4 +2,3 @@
2
2
  public static function hello(arg : String) {
3
3
  return 'Hello $arg';
4
4
  }
5
-
@@ -0,0 +1,13 @@
1
+ import Data.Vect
2
+
3
+ insert : Ord elem =>
4
+ (x : elem) -> (xsSorted : Vect len elem) -> Vect (S len) elem
5
+ insert x [] = [x]
6
+ insert x (y :: xs) = case x < y of
7
+ True => x :: y :: xs
8
+ False => y :: insert x xs
9
+
10
+ insSort : Ord elem => Vect n elem -> Vect n elem
11
+ insSort [] = []
12
+ insSort (x :: xs) = let xsSorted = insSort xs in
13
+ insert x xsSorted
@@ -0,0 +1,16 @@
1
+ theory demo imports Main begin
2
+
3
+ section ‹Inductive predicates for lists›
4
+
5
+ datatype 'a list = Nil ("[]") | Cons 'a "'a list" ("_ # _")
6
+
7
+ fun length :: "'a list ⇒ nat" where
8
+ "length [] = 0" | "length (x # xs) = 1 + length xs"
9
+
10
+ inductive ζ :: "'a list ⇒ nat ⇒ bool" where
11
+ Nil[intro!]: "ζ [] 0" |
12
+ Cons[intro]: "ζ xs l ⟹ ζ (x # xs) (1 + l)"
13
+
14
+ (* Not the answer? *)
15
+ lemma "ζ xs 42"
16
+ oops
@@ -0,0 +1,8 @@
1
+ open nat
2
+
3
+ def add : nat → nat → nat
4
+ | m zero := m
5
+ | m (succ n) := succ (add m n)
6
+
7
+ -- encode definition as an axiom
8
+ axiom add_zero (n : nat) : n + 0 = n
@@ -0,0 +1,10 @@
1
+ project('tutorial', 'c', version: '0.2.3')
2
+ executable('demo', 'main.c')
3
+
4
+ version_array = meson.project_version().split('.')
5
+ api_version = '@0@.@1@'.format(version_array[0], version_array[1])
6
+
7
+ d = dependency('foo', required : get_option('myfeature'))
8
+ if d.found()
9
+ app = executable('app', 'app.c', dependencies : [d])
10
+ endif
@@ -8,4 +8,4 @@ Reset:
8
8
  lda #$3f ; $3F -> A register
9
9
  ldy #$00 ; $00 -> Y register
10
10
  sta PPU_ADDR ; write #HIGH byte first
11
- sty PPU_ADDR ; $3F00 -> PPU address
11
+ sty PPU_ADDR ; $3F00 -> PPU address
@@ -0,0 +1,35 @@
1
+ % Functional Recursion: ;
2
+ fact IS RECUR [ 0 =, 1 first, pass, product, -1 +] % from wikipedia;
3
+
4
+ % Product of a range: ;
5
+ fact IS * count;
6
+
7
+ % Plain recursion: ;
8
+ fact IS OPERATION x {
9
+ if x = 0 then 1 else x * fact (x - 1) endif
10
+ };
11
+
12
+ % While loop: ;
13
+ fact IS OPERATION x {
14
+ prod := 1;
15
+ WHILE x > 0 DO
16
+ prod := prod * x;
17
+ x := x - 1;
18
+ ENDWHILE;
19
+ prod
20
+ }
21
+
22
+ % A basic divide by zero error: ;
23
+ 1 / 0
24
+ # OUTPUT:
25
+ ?div
26
+
27
+ % Errors are also values called faults, giving you their location: ;
28
+ 5 / 5 10 0 8
29
+ # OUTPUT:
30
+ 1. 0.5 ?div 0.625
31
+
32
+ % You can also define custom faults using 'fault': ;
33
+ fault 'this is an error'
34
+ # OUTPUT:
35
+ this is an error
@@ -3,4 +3,3 @@ languagesystem DFLT dflt;
3
3
  feature liga {
4
4
  sub f i by f_i;
5
5
  } liga;
6
-
@@ -0,0 +1,2 @@
1
+ SELECT q'{a quoted string}' AS s, TO_CHAR(SYSDATE,'MM/DD/YYYY') AS "Current Date" FROM DUAL
2
+ WHERE 1=1;
@@ -0,0 +1,33 @@
1
+ // A system agnostic domain specific language for runtime monitoring and verification
2
+ // Basic events
3
+
4
+ insert(index,elem) matches {event:'func_pre',name:'my_insert',args:[index,elem]};
5
+
6
+ relevant matches insert(_,_)|remove(_,_)|size(_)|get(_,_);
7
+
8
+ insert_in_bounds(size) matches insert(index,_) with index >= 0 && index <= size;
9
+
10
+ del_false matches del(_,false);
11
+ not_add_true_del(el) not matches add(el,true) | del(el,_);
12
+
13
+ Main = relevant >> (CheckIndex<0> /\ add_rm_get >> CheckElem)!;
14
+ CheckIndex<size> =
15
+ get_size(size)* (insert_in_bounds(size) CheckIndex<size+1> \/ remove_in_bounds(size) CheckIndex<size-1>);
16
+
17
+ Msg<inf,sup> = if(inf<=sup) msg(inf) Msg<inf+1,sup> else empty;
18
+ Main=relevant>>Msg<1,4>*!;
19
+
20
+ acquire(id) matches {event:'func_pre',name:'acquire',args:[_,id,...]};
21
+
22
+ Main = relevant >> Resources;
23
+ Resources =
24
+ {let id; acquire(id)
25
+ ((Resources | use(id)* release(id)) /\
26
+ acqRel(id) >> release(id) all)
27
+ }?;
28
+
29
+ msg(ty) matches {event:'func_pre',name:'msg',args:[ty]};
30
+ relevant matches msg(_);
31
+
32
+ Msg<inf,sup> = if(inf<=sup) msg(inf) Msg<inf+1,sup> else empty;
33
+ Main=relevant>>Msg<1,4>*!;
@@ -9,4 +9,3 @@
9
9
  </ul>
10
10
 
11
11
  <div class="{if $foo}class1{else}class2{/if}">{$foo.bar.baz}</div>
12
-
@@ -0,0 +1,15 @@
1
+ include <linux/test.h>
2
+
3
+ resource fd_test[fd]
4
+
5
+ openat$test(fd const[AT_FDCWD], file ptr[in, string["/dev/test"]], flags flags[open_flags], mode const[0]) fd_test
6
+
7
+ ioctl$TEST(fd fd_test, cmd const[TEST], arg ptr[in, test])
8
+
9
+ test {
10
+ number int32
11
+ size len[data, int32]
12
+ data array[int8]
13
+ }
14
+
15
+ _ = TEST
@@ -0,0 +1,8 @@
1
+ # Source: https://github.com/google/syzkaller/blob/master/sys/linux/test/vusb_hid
2
+
3
+ r0 = syz_usb_connect$hid(0x0, 0x36, &(0x7f0000000040)=ANY=[@ANYBLOB="12010000000018105e04da07000000000001090224000100000000090400000903000000092100000001222200090581030800000000"], 0x0)
4
+ syz_usb_control_io$hid(r0, 0x0, 0x0)
5
+ syz_usb_control_io$hid(r0, &(0x7f00000001c0)={0x24, 0x0, 0x0, &(0x7f0000000000)={0x0, 0x22, 0x22, {[@global=@item_012={0x2, 0x1, 0x9, "2313"}, @global=@item_012={0x2, 0x1, 0x0, "e53f"}, @global=@item_4={0x3, 0x1, 0x0, '\f\x00'}, @local=@item_012={0x2, 0x2, 0x2, "9000"}, @global=@item_4={0x3, 0x1, 0x0, "0900be00"}, @main=@item_4={0x3, 0x0, 0x8, '\x00'}, @local=@item_4={0x3, 0x2, 0x0, "09007a15"}, @local=@item_4={0x3, 0x2, 0x0, "5d8c3dda"}]}}, 0x0}, 0x0)
6
+ syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB')
7
+ syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB')
8
+ syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB')
@@ -28,4 +28,3 @@ module Rouge
28
28
  end
29
29
  end
30
30
  end
31
-
@@ -131,6 +131,13 @@ module Rouge
131
131
  next TeX if matches?(/\A\s*(?:\\|%)/)
132
132
  next Apex
133
133
  end
134
+
135
+ disambiguate '*.pp' do
136
+ next Pascal if matches?(/\b(function|begin|var)\b/)
137
+ next Pascal if matches?(/\b(end(;|\.))/)
138
+
139
+ Puppet
140
+ end
134
141
  end
135
142
  end
136
143
  end
data/lib/rouge/lexer.rb CHANGED
@@ -293,8 +293,8 @@ module Rouge
293
293
 
294
294
  # @private
295
295
  def assert_utf8!(str)
296
- encoding = str.encoding.name
297
- return if encoding == 'US-ASCII' || encoding == 'UTF-8' || encoding == 'ASCII-8BIT'
296
+ encoding = str.encoding
297
+ return if encoding == Encoding::US_ASCII || encoding == Encoding::UTF_8 || encoding == Encoding::BINARY
298
298
 
299
299
  raise EncodingError.new(
300
300
  "Bad encoding: #{str.encoding.names.join(',')}. " +
@@ -21,4 +21,4 @@ module Rouge
21
21
  end
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -5,7 +5,7 @@ module Rouge
5
5
  module Lexers
6
6
  class AppleScript < RegexLexer
7
7
  title "AppleScript"
8
- desc "The AppleScript scripting language by Apple Inc. (http://developer.apple.com/applescript/)"
8
+ desc "The AppleScript scripting language by Apple Inc. (https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html)"
9
9
 
10
10
  tag 'applescript'
11
11
  aliases 'applescript'
@@ -71,6 +71,7 @@ module Rouge
71
71
  rule %r/\bnullptr\b/, Name::Builtin
72
72
  rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
73
73
  rule %r/(::|<=>)/, Operator
74
+ rule %r/[{}]/, Punctuation
74
75
  end
75
76
 
76
77
  state :classname do
@@ -61,7 +61,8 @@ module Rouge
61
61
 
62
62
  rule %r/#{id}:/, Name::Label
63
63
  rule %r/\$?#{id}/, Name
64
- rule %r/[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
64
+ rule %r/[~^*!%&\|+=:\/?-]/, Operator
65
+ rule %r/[\[\](){}<>\.,;]/, Punctuation
65
66
  rule %r/\d*\.\d+([eE]\-?\d+)?/, Num::Float
66
67
  rule %r/0x[\da-fA-F]+/, Num::Hex
67
68
  rule %r/\d+L?/, Num::Integer
@@ -20,9 +20,19 @@ module Rouge
20
20
  state :root do
21
21
  rule(/^ .*$\n?/, Text)
22
22
  rule(/^---$\n?/, Punctuation)
23
- rule(/^[+>]+.*$\n?/, Generic::Inserted)
24
- rule(/^\+.*$\n?/, Generic::Inserted)
25
- rule(/^[-<]+.*$\n?/, Generic::Deleted)
23
+
24
+ rule %r(
25
+ (^\++.*$\n?) |
26
+ (^>+[ \t]+.*$\n?) |
27
+ (^>+$\n?)
28
+ )x, Generic::Inserted
29
+
30
+ rule %r(
31
+ (^-+.*$\n?) |
32
+ (^<+[ \t]+.*$\n?) |
33
+ (^<+$\n?)
34
+ )x, Generic::Deleted
35
+
26
36
  rule(/^!.*$\n?/, Generic::Strong)
27
37
  rule(/^([Ii]ndex|diff).*$\n?/, Generic::Heading)
28
38
  rule(/^(@@[^@]*@@)([^\n]*\n)/) do
@@ -30,7 +40,7 @@ module Rouge
30
40
  end
31
41
  rule(/^\w.*$\n?/, Punctuation)
32
42
  rule(/^=.*$\n?/, Generic::Heading)
33
- rule(/\s.*$\n?/, Text)
43
+ rule(/.+$\n?/, Text)
34
44
  end
35
45
  end
36
46
  end
@@ -20,6 +20,10 @@ module Rouge
20
20
  state :root do
21
21
  rule %r/\s+/, Text
22
22
 
23
+ rule %r/^(FROM)(\s+)(.*)(\s+)(AS)(\s+)(.*)/io do
24
+ groups Keyword, Text::Whitespace, Str, Text::Whitespace, Keyword, Text::Whitespace, Str
25
+ end
26
+
23
27
  rule %r/^(ONBUILD)(\s+)(#{KEYWORDS})(.*)/io do
24
28
  groups Keyword, Text::Whitespace, Keyword, Str
25
29
  end
@@ -63,4 +63,3 @@ module Rouge
63
63
  end
64
64
  end
65
65
  end
66
-
@@ -16,4 +16,4 @@ module Rouge
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -7,7 +7,7 @@ module Rouge
7
7
  title "Groovy"
8
8
  desc 'The Groovy programming language (http://www.groovy-lang.org/)'
9
9
  tag 'groovy'
10
- filenames '*.groovy', 'Jenkinsfile'
10
+ filenames '*.groovy', 'Jenkinsfile', '*.Jenkinsfile'
11
11
  mimetypes 'text/x-groovy'
12
12
 
13
13
  def self.detect?(text)
@@ -88,4 +88,4 @@ module Rouge
88
88
  end
89
89
  end
90
90
  end
91
- end
91
+ end
@@ -17,15 +17,15 @@ module Rouge
17
17
 
18
18
  def self.keywords
19
19
  @keywords ||= Set.new %w(
20
- break case cast catch class continue default do else enum false for
21
- function if import interface macro new null override package private
20
+ as break case cast catch class continue default do else enum false for
21
+ function if import in interface macro new null override package private
22
22
  public return switch this throw true try untyped while
23
23
  )
24
24
  end
25
25
 
26
26
  def self.imports
27
27
  @imports ||= Set.new %w(
28
- import using
28
+ package import using
29
29
  )
30
30
  end
31
31
 
@@ -55,6 +55,7 @@ module Rouge
55
55
  end
56
56
 
57
57
  id = /[$a-zA-Z_][a-zA-Z0-9_]*/
58
+ dotted_id = /[$a-zA-Z_][a-zA-Z0-9_.]*/
58
59
 
59
60
  state :comments_and_whitespace do
60
61
  rule %r/\s+/, Text
@@ -77,6 +78,22 @@ module Rouge
77
78
  rule %r//, Text, :pop!
78
79
  end
79
80
 
81
+ state :namespace do
82
+ mixin :comments_and_whitespace
83
+
84
+ rule %r/
85
+ (#{dotted_id})
86
+ (\s+)(in|as)(\s+)
87
+ (#{id})
88
+ /x do
89
+ groups(Name::Namespace, Text::Whitespace, Keyword, Text::Whitespace, Name)
90
+ end
91
+
92
+ rule %r/#{dotted_id}/, Name::Namespace
93
+
94
+ rule(//) { pop! }
95
+ end
96
+
80
97
  state :regex do
81
98
  rule %r(/) do
82
99
  token Str::Regex
@@ -141,20 +158,22 @@ module Rouge
141
158
  end
142
159
 
143
160
  rule id do |m|
144
- if self.class.keywords.include? m[0]
161
+ match = m[0]
162
+
163
+ if self.class.imports.include?(match)
164
+ token Keyword::Namespace
165
+ push :namespace
166
+ elsif self.class.keywords.include?(match)
145
167
  token Keyword
146
168
  push :expr_start
147
- elsif self.class.imports.include? m[0]
148
- token Keyword
149
- push :namespace
150
- elsif self.class.declarations.include? m[0]
169
+ elsif self.class.declarations.include?(match)
151
170
  token Keyword::Declaration
152
171
  push :expr_start
153
- elsif self.class.reserved.include? m[0]
172
+ elsif self.class.reserved.include?(match)
154
173
  token Keyword::Reserved
155
- elsif self.class.constants.include? m[0]
174
+ elsif self.class.constants.include?(match)
156
175
  token Keyword::Constant
157
- elsif self.class.builtins.include? m[0]
176
+ elsif self.class.builtins.include?(match)
158
177
  token Name::Builtin
159
178
  else
160
179
  token Name::Other
@@ -46,7 +46,7 @@ module Rouge
46
46
 
47
47
  # response
48
48
  rule %r(
49
- (HTTPS?)(/)(\d(?:\.\d))([ ]+) # http version
49
+ (HTTPS?)(/)(\d(?:\.\d)?)([ ]+) # http version
50
50
  (\d{3})([ ]+)? # status
51
51
  ([^\r\n]*)?(\r?\n|$) # status message
52
52
  )x do
@@ -91,4 +91,3 @@ module Rouge
91
91
  end
92
92
  end
93
93
  end
94
-