rouge 2.0.3 → 2.0.5

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
  SHA1:
3
- metadata.gz: 93043d4d750807111180be1a7d6582d7d8338470
4
- data.tar.gz: 9b99367f2a290e9c4c0a040142866a641bb06803
3
+ metadata.gz: 9e86ab14104619c2550743be376277431a1d348a
4
+ data.tar.gz: dd494f5310e3f05ea124ba5009c1ee93835591b9
5
5
  SHA512:
6
- metadata.gz: 302965016c0054702b7a0e97c1d8fecb6a755ae4957e127870e2d6eecd4131d8589e4f20b6c44b751edcceb0d3030cdfa27004ac9388d6b44e72b0133451a6f9
7
- data.tar.gz: 52de7875d8d80e34c93cec6c86afdf8292bebfeabcac389a746c18b95bd46bb070b9410020ca609bd4beec241fdf243a07792cc927a4b7832254005f007c40c1
6
+ metadata.gz: 199f707e796ee258424385a3e04347fee7f3ac56062d1bd1d0498eb0cef816a6d9944bd93cadb7cc390da3ca8191be3a8da407c0e2372e4cc209867a9a76ac6b
7
+ data.tar.gz: b48cc7207849973dc09b789c6d0379d3a0ab5d4f364c5d8ca0b7db2f53879f1865b8574b22d1dd9bdb32e39f09ff52aa261db44e29a062d1862b7f68aa687ff4
@@ -0,0 +1,9 @@
1
+ maintainer First O'Last
2
+
3
+ run echo \
4
+ 123 $bar
5
+ # comment
6
+ onbuild add . /app/src
7
+ onbuild run echo \
8
+ 123 $bar
9
+ CMD /bin/bash
@@ -0,0 +1,12 @@
1
+ (* Binary tree with leaves car­rying an integer. *)
2
+ type Tree = Leaf of int | Node of Tree * Tree
3
+
4
+ let rec existsLeaf test tree =
5
+ match tree with
6
+ | Leaf v -> test v
7
+ | Node (left, right) ->
8
+ existsLeaf test left
9
+ || existsLeaf test right
10
+
11
+ let hasEvenLeaf tree =
12
+ existsLeaf (fun n -> n % 2 = 0) tree
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Docker < RegexLexer
6
+ title "Docker"
7
+ desc "Dockerfile syntax"
8
+ tag 'docker'
9
+ aliases 'dockerfile'
10
+ filenames 'Dockerfile', '*.docker'
11
+ mimetypes 'text/x-dockerfile-config'
12
+
13
+ KEYWORDS = %w(
14
+ FROM MAINTAINER CMD EXPOSE ENV ADD ENTRYPOINT VOLUME WORKDIR
15
+ ).join('|')
16
+
17
+ start { @shell = Shell.new(@options) }
18
+
19
+ state :root do
20
+ rule /\s+/, Text
21
+
22
+ rule /^(ONBUILD)(\s+)(#{KEYWORDS})(.*)/io do |m|
23
+ groups Keyword, Text::Whitespace, Keyword, Str
24
+ end
25
+
26
+ rule /^(#{KEYWORDS})\b(.*)/io do |m|
27
+ groups Keyword, Str
28
+ end
29
+
30
+ rule /#.*?$/, Comment
31
+
32
+ rule /^(ONBUILD\s+)?RUN(\s+)/i do
33
+ token Keyword
34
+ push :run
35
+ @shell.reset!
36
+ end
37
+
38
+ rule /\w+/, Text
39
+ rule /[^\w]+/, Text
40
+ rule /./, Text
41
+ end
42
+
43
+ state :run do
44
+ rule /\n/, Text, :pop!
45
+ rule /\\./m, Str::Escape
46
+ rule(/(\\.|[^\n\\])+/) { delegate @shell }
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,118 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class FSharp < RegexLexer
6
+ title "FSharp"
7
+ desc 'F# (fsharp.net)'
8
+ tag 'fsharp'
9
+ filenames '*.fs', '*.fsx'
10
+ mimetypes 'application/fsharp-script', 'text/x-fsharp', 'text/x-fsi'
11
+
12
+ def self.keywords
13
+ @keywords ||= Set.new %w(
14
+ abstract and as assert base begin class default delegate do
15
+ done downcast downto elif else end exception extern false
16
+ finally for fun function global if in inherit inline interface
17
+ internal lazy let let! match member module mutable namespace
18
+ new not null of open or override private public rec return
19
+ return! select static struct then to true try type upcast
20
+ use use! val void when while with yield yield! sig atomic
21
+ break checked component const constraint constructor
22
+ continue eager event external fixed functor include method
23
+ mixin object parallel process protected pure sealed tailcall
24
+ trait virtual volatile
25
+ )
26
+ end
27
+
28
+ def self.keyopts
29
+ @keyopts ||= Set.new %w(
30
+ != # & && ( ) * \+ , - -. -> . .. : :: := :> ; ;; < <- =
31
+ > >] >} ? ?? [ [< [> [| ] _ ` { {< | |] } ~ |> <| <>
32
+ )
33
+ end
34
+
35
+ def self.word_operators
36
+ @word_operators ||= Set.new %w(and asr land lor lsl lxor mod or)
37
+ end
38
+
39
+ def self.primitives
40
+ @primitives ||= Set.new %w(unit int float bool string char list array)
41
+ end
42
+
43
+ operator = %r([\[\];,{}_()!$%&*+./:<=>?@^|~#-]+)
44
+ id = /[a-z][\w']*/i
45
+ upper_id = /[A-Z][\w']*/
46
+
47
+ state :root do
48
+ rule /\s+/m, Text
49
+ rule /false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
50
+ rule /#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
51
+ rule upper_id, Name::Class
52
+ rule /[(][*](?![)])/, Comment, :comment
53
+ rule %r(//.*?\n), Comment::Single
54
+ rule id do |m|
55
+ match = m[0]
56
+ if self.class.keywords.include? match
57
+ token Keyword
58
+ elsif self.class.word_operators.include? match
59
+ token Operator::Word
60
+ elsif self.class.primitives.include? match
61
+ token Keyword::Type
62
+ else
63
+ token Name
64
+ end
65
+ end
66
+
67
+ rule operator do |m|
68
+ match = m[0]
69
+ if self.class.keyopts.include? match
70
+ token Punctuation
71
+ else
72
+ token Operator
73
+ end
74
+ end
75
+
76
+ rule /-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
77
+ rule /0x\h[\h_]*/i, Num::Hex
78
+ rule /0o[0-7][0-7_]*/i, Num::Oct
79
+ rule /0b[01][01_]*/i, Num::Bin
80
+ rule /\d[\d_]*/, Num::Integer
81
+
82
+ rule /'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
83
+ rule /'[.]'/, Str::Char
84
+ rule /'/, Keyword
85
+ rule /"/, Str::Double, :string
86
+ rule /[~?]#{id}/, Name::Variable
87
+ end
88
+
89
+ state :comment do
90
+ rule /[^(*)]+/, Comment
91
+ rule(/[(][*]/) { token Comment; push }
92
+ rule /[*][)]/, Comment, :pop!
93
+ rule /[(*)]/, Comment
94
+ end
95
+
96
+ state :string do
97
+ rule /[^\\"]+/, Str::Double
98
+ mixin :escape_sequence
99
+ rule /\\\n/, Str::Double
100
+ rule /"/, Str::Double, :pop!
101
+ end
102
+
103
+ state :escape_sequence do
104
+ rule /\\[\\"'ntbr]/, Str::Escape
105
+ rule /\\\d{3}/, Str::Escape
106
+ rule /\\x\h{2}/, Str::Escape
107
+ end
108
+
109
+ state :dotted do
110
+ rule /\s+/m, Text
111
+ rule /[.]/, Punctuation
112
+ rule /#{upper_id}(?=\s*[.])/, Name::Namespace
113
+ rule upper_id, Name::Class, :pop!
114
+ rule id, Name, :pop!
115
+ end
116
+ end
117
+ end
118
+ end
@@ -10,7 +10,7 @@ module Rouge
10
10
  # Author: Sri Harsha Chilakapati
11
11
  class Glsl < C
12
12
  tag 'glsl'
13
- filenames '*.glsl', '*.frag', '*.vert', '*.geom', '*.fs', '*.vs', '*.gs', '*.shader'
13
+ filenames '*.glsl', '*.frag', '*.vert', '*.geom', '*.vs', '*.gs', '*.shader'
14
14
  mimetypes 'x-shader/x-vertex', 'x-shader/x-fragment', 'x-shader/x-geometry'
15
15
 
16
16
  title "GLSL"
@@ -107,14 +107,14 @@ module Rouge
107
107
 
108
108
  # TODO: not in python 3
109
109
  rule /`.*?`/, Str::Backtick
110
- rule /(?:r|ur|ru)"""/i, Str, :tdqs
111
- rule /(?:r|ur|ru)'''/i, Str, :tsqs
112
- rule /(?:r|ur|ru)"/i, Str, :dqs
113
- rule /(?:r|ur|ru)'/i, Str, :sqs
114
- rule /u?"""/i, Str, :escape_tdqs
115
- rule /u?'''/i, Str, :escape_tsqs
116
- rule /u?"/i, Str, :escape_dqs
117
- rule /u?'/i, Str, :escape_sqs
110
+ rule /(?:r|ur|ru)"""/i, Str, :raw_tdqs
111
+ rule /(?:r|ur|ru)'''/i, Str, :raw_tsqs
112
+ rule /(?:r|ur|ru)"/i, Str, :raw_dqs
113
+ rule /(?:r|ur|ru)'/i, Str, :raw_sqs
114
+ rule /u?"""/i, Str, :tdqs
115
+ rule /u?'''/i, Str, :tsqs
116
+ rule /u?"/i, Str, :dqs
117
+ rule /u?'/i, Str, :sqs
118
118
 
119
119
  rule /@#{dotted_identifier}/i, Name::Decorator
120
120
 
@@ -204,7 +204,7 @@ module Rouge
204
204
  rule %r(\\
205
205
  ( [\\abfnrtv"']
206
206
  | \n
207
- | N{.*?}
207
+ | N{[a-zA-z][a-zA-Z ]+[a-zA-Z]}
208
208
  | u[a-fA-F0-9]{4}
209
209
  | U[a-fA-F0-9]{8}
210
210
  | x[a-fA-F0-9]{2}
@@ -213,21 +213,26 @@ module Rouge
213
213
  )x, Str::Escape
214
214
  end
215
215
 
216
+ state :raw_escape do
217
+ rule /\\./, Str
218
+ end
219
+
216
220
  state :dqs do
217
221
  rule /"/, Str, :pop!
218
- rule /\\\\|\\"|\\\n/, Str::Escape
222
+ mixin :escape
219
223
  mixin :strings_double
220
224
  end
221
225
 
222
226
  state :sqs do
223
227
  rule /'/, Str, :pop!
224
- rule /\\\\|\\'|\\\n/, Str::Escape
228
+ mixin :escape
225
229
  mixin :strings_single
226
230
  end
227
231
 
228
232
  state :tdqs do
229
233
  rule /"""/, Str, :pop!
230
234
  rule /"/, Str
235
+ mixin :escape
231
236
  mixin :strings_double
232
237
  mixin :nl
233
238
  end
@@ -235,13 +240,14 @@ module Rouge
235
240
  state :tsqs do
236
241
  rule /'''/, Str, :pop!
237
242
  rule /'/, Str
243
+ mixin :escape
238
244
  mixin :strings_single
239
245
  mixin :nl
240
246
  end
241
247
 
242
248
  %w(tdqs tsqs dqs sqs).each do |qtype|
243
- state :"escape_#{qtype}" do
244
- mixin :escape
249
+ state :"raw_#{qtype}" do
250
+ mixin :raw_escape
245
251
  mixin :"#{qtype}"
246
252
  end
247
253
  end
@@ -63,6 +63,7 @@ module Rouge
63
63
 
64
64
  def set_indent(match, opts={})
65
65
  if indent < @next_indent
66
+ puts " yaml: indenting #{indent}/#{@next_indent}" if @debug
66
67
  @indent_stack << @next_indent
67
68
  end
68
69
 
@@ -122,7 +123,10 @@ module Rouge
122
123
  end
123
124
 
124
125
  # block collection indicators
125
- rule(/[?:-](?=[ ]|$)/) { |m| token Punctuation::Indicator; set_indent m[0] }
126
+ rule(/[?:-](?=[ ]|$)/) do |m|
127
+ set_indent m[0]
128
+ token Punctuation::Indicator
129
+ end
126
130
 
127
131
  # the beginning of a block line
128
132
  rule(/[ ]*/) { |m| token Text; continue_indent(m[0]); pop! }
@@ -166,8 +170,8 @@ module Rouge
166
170
 
167
171
  state :block_nodes do
168
172
  # implicit key
169
- rule /:(?=\s|$)/ do |m|
170
- token Punctuation::Indicator
173
+ rule /((?:\w[\w -]*)?)(:)(?=\s|$)/ do |m|
174
+ groups Name::Attribute, Punctuation::Indicator
171
175
  set_indent m[0], :implicit => true
172
176
  end
173
177
 
@@ -233,7 +237,9 @@ module Rouge
233
237
  @block_scalar_indent ||= indent_size
234
238
 
235
239
  if indent_size < dedent_level
236
- pop! 2
240
+ save_indent m[0]
241
+ pop!
242
+ push :indentation
237
243
  end
238
244
  end
239
245
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rouge
4
4
  def self.version
5
- "2.0.3"
5
+ "2.0.5"
6
6
  end
7
7
  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: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-19 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:
@@ -43,12 +43,14 @@ files:
43
43
  - lib/rouge/demos/d
44
44
  - lib/rouge/demos/dart
45
45
  - lib/rouge/demos/diff
46
+ - lib/rouge/demos/docker
46
47
  - lib/rouge/demos/eiffel
47
48
  - lib/rouge/demos/elixir
48
49
  - lib/rouge/demos/erb
49
50
  - lib/rouge/demos/erlang
50
51
  - lib/rouge/demos/factor
51
52
  - lib/rouge/demos/fortran
53
+ - lib/rouge/demos/fsharp
52
54
  - lib/rouge/demos/gherkin
53
55
  - lib/rouge/demos/glsl
54
56
  - lib/rouge/demos/go
@@ -162,12 +164,14 @@ files:
162
164
  - lib/rouge/lexers/d.rb
163
165
  - lib/rouge/lexers/dart.rb
164
166
  - lib/rouge/lexers/diff.rb
167
+ - lib/rouge/lexers/docker.rb
165
168
  - lib/rouge/lexers/eiffel.rb
166
169
  - lib/rouge/lexers/elixir.rb
167
170
  - lib/rouge/lexers/erb.rb
168
171
  - lib/rouge/lexers/erlang.rb
169
172
  - lib/rouge/lexers/factor.rb
170
173
  - lib/rouge/lexers/fortran.rb
174
+ - lib/rouge/lexers/fsharp.rb
171
175
  - lib/rouge/lexers/gherkin.rb
172
176
  - lib/rouge/lexers/gherkin/keywords.rb
173
177
  - lib/rouge/lexers/glsl.rb