rouge 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/bin/rougify +1 -1
- data/lib/rouge/cli.rb +1 -0
- data/lib/rouge/demos/gherkin +1 -1
- data/lib/rouge/demos/nix +19 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/null.rb +1 -1
- data/lib/rouge/formatters/terminal256.rb +11 -3
- data/lib/rouge/lexers/fortran.rb +34 -28
- data/lib/rouge/lexers/igorpro.rb +11 -10
- data/lib/rouge/lexers/javascript.rb +15 -3
- data/lib/rouge/lexers/kotlin.rb +1 -1
- data/lib/rouge/lexers/nix.rb +205 -0
- data/lib/rouge/lexers/q.rb +5 -2
- data/lib/rouge/text_analyzer.rb +1 -0
- data/lib/rouge/version.rb +1 -1
- data/rouge.gemspec +4 -1
- metadata +35 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a52694e10ac2f03c8d2eadd1379cd10d3218df7
|
4
|
+
data.tar.gz: e7962a37f67e9fa857c066879f265e04b61bd553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55cc1e3ca7c1db144a7c4df78bbab3c8af73367006072ea2d579b9d3d9c5d31234721e5c0cf82ad84fe315c070e9689287a8a0e586df6a1a231a951934726f7
|
7
|
+
data.tar.gz: f6a5777bacb090afc87ef413ab4bb069e15bc7a25ef72450565ae2994eb31d24e4e8b0eb08ae5494fdb03cdb0172fc7902040ffa14646133f7ae6fdf6597021c
|
data/Gemfile
CHANGED
data/bin/rougify
CHANGED
@@ -4,7 +4,7 @@ require 'pathname'
|
|
4
4
|
ROOT_DIR = Pathname.new(__FILE__).dirname.parent
|
5
5
|
load ROOT_DIR.join('lib/rouge.rb')
|
6
6
|
load ROOT_DIR.join('lib/rouge/cli.rb')
|
7
|
-
Signal.trap('
|
7
|
+
Signal.trap('PIPE', 'SYSTEM_DEFAULT') if Signal.list.include? 'PIPE'
|
8
8
|
|
9
9
|
begin
|
10
10
|
Rouge::CLI.parse(ARGV).run
|
data/lib/rouge/cli.rb
CHANGED
@@ -273,6 +273,7 @@ module Rouge
|
|
273
273
|
when 'html-pygments' then Formatters::HTMLPygments.new(Formatters::HTML.new, opts[:css_class])
|
274
274
|
when 'html-inline' then Formatters::HTMLInline.new(theme)
|
275
275
|
when 'html-table' then Formatters::HTMLTable.new(Formatters::HTML.new)
|
276
|
+
when 'null', 'raw', 'tokens' then Formatters::Null.new
|
276
277
|
else
|
277
278
|
error! "unknown formatter preset #{opts[:formatter]}"
|
278
279
|
end
|
data/lib/rouge/demos/gherkin
CHANGED
data/lib/rouge/demos/nix
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# See https://nixos.org/nix/manual/#sec-expression-syntax
|
2
|
+
{ stdenv, fetchurl, perl }: # 1
|
3
|
+
|
4
|
+
stdenv.mkDerivation { # 2
|
5
|
+
name = "hello-2.1.1"; # 3
|
6
|
+
builder = ./builder.sh; # 4
|
7
|
+
meta = rec {
|
8
|
+
name = "rouge";
|
9
|
+
version = "${name}-2.1.1";
|
10
|
+
number = 55 + 12;
|
11
|
+
isSmaller = number < 42;
|
12
|
+
bool = true;
|
13
|
+
};
|
14
|
+
src = fetchurl { # 5
|
15
|
+
url = ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz; # path
|
16
|
+
md5 = "70c9ccf9fac07f762c24f2df2290784d";
|
17
|
+
};
|
18
|
+
inherit perl; # 6
|
19
|
+
}
|
data/lib/rouge/formatter.rb
CHANGED
@@ -4,13 +4,21 @@ module Rouge
|
|
4
4
|
module Formatters
|
5
5
|
# A formatter for 256-color terminals
|
6
6
|
class Terminal256 < Formatter
|
7
|
+
tag 'terminal256'
|
8
|
+
|
7
9
|
# @private
|
8
10
|
attr_reader :theme
|
9
11
|
|
10
|
-
# @
|
12
|
+
# @param [Hash,Rouge::Theme] theme
|
11
13
|
# the theme to render with.
|
12
|
-
def initialize(theme=
|
13
|
-
|
14
|
+
def initialize(theme = Themes::ThankfulEyes.new)
|
15
|
+
if theme.is_a?(Rouge::Theme)
|
16
|
+
@theme = theme
|
17
|
+
elsif theme.is_a?(Hash)
|
18
|
+
@theme = theme[:theme] || Themes::ThankfulEyes.new
|
19
|
+
else
|
20
|
+
raise ArgumentError, "invalid theme: #{theme.inspect}"
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
def stream(tokens, &b)
|
data/lib/rouge/lexers/fortran.rb
CHANGED
@@ -19,27 +19,30 @@ module Rouge
|
|
19
19
|
exponent = /[ED][+-]?\d+/i
|
20
20
|
|
21
21
|
def self.keywords
|
22
|
-
#
|
22
|
+
# Special rules for two-word keywords are defined further down.
|
23
|
+
# Note: Fortran allows to omit whitespace between certain keywords.
|
23
24
|
@keywords ||= Set.new %w(
|
24
|
-
abstract
|
25
|
-
backspace bind block blockdata
|
26
|
-
|
27
|
-
deferred dimension do elemental else elseif elsewhere end
|
28
|
-
endblockdata enddo endenum endfile endforall
|
29
|
-
endinterface endmodule endprogram endselect
|
30
|
-
endtype endwhere endwhile entry enum
|
31
|
-
external final flush forall format
|
32
|
-
implicit import in include inout inquire
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
type use value volatile
|
25
|
+
abstract allocatable allocate assign assignment associate asynchronous
|
26
|
+
backspace bind block blockdata call case class close codimension
|
27
|
+
common concurrent contains contiguous continue critical cycle data
|
28
|
+
deallocate deferred dimension do elemental else elseif elsewhere end
|
29
|
+
endassociate endblock endblockdata enddo endenum endfile endforall
|
30
|
+
endfunction endif endinterface endmodule endprogram endselect
|
31
|
+
endsubmodule endsubroutine endtype endwhere endwhile entry enum
|
32
|
+
enumerator equivalence exit extends external final flush forall format
|
33
|
+
function generic goto if implicit import in include inout inquire
|
34
|
+
intent interface intrinsic is lock module namelist non_overridable
|
35
|
+
none nopass nullify only open operator optional out parameter pass
|
36
|
+
pause pointer print private procedure program protected public pure
|
37
|
+
read recursive result return rewind save select selectcase sequence
|
38
|
+
stop submodule subroutine target then type unlock use value volatile
|
39
|
+
wait where while write
|
38
40
|
)
|
39
41
|
end
|
40
42
|
|
41
43
|
def self.types
|
42
|
-
#
|
44
|
+
# A special rule for the two-word version "double precision" is
|
45
|
+
# defined further down.
|
43
46
|
@types ||= Set.new %w(
|
44
47
|
character complex doubleprecision integer logical real
|
45
48
|
)
|
@@ -48,16 +51,16 @@ module Rouge
|
|
48
51
|
def self.intrinsics
|
49
52
|
@intrinsics ||= Set.new %w(
|
50
53
|
abs achar acos acosh adjustl adjustr aimag aint all allocated anint
|
51
|
-
any asin asinh associated atan atan2 atanh
|
52
|
-
bessel_jn bessel_y0 bessel_y1 bessel_yn bge bgt
|
53
|
-
c_associated c_f_pointer c_f_procpointer
|
54
|
-
ceiling char cmplx command_argument_count
|
55
|
-
compiler_version conjg cos cosh count cpu_time cshift
|
56
|
-
dble digits dim dot_product dprod dshiftl dshiftr
|
57
|
-
erfc_scaled erfc execute_command_line exp exponent
|
58
|
-
findloc floor fraction gamma get_command_argument
|
59
|
-
get_environment_variable huge hypot iachar iall iand iany
|
60
|
-
ibset ichar ieee_class ieee_copy_sign ieee_get_flag
|
54
|
+
any asin asinh associated atan atan2 atanh atomic_define atomic_ref
|
55
|
+
bessel_j0 bessel_j1 bessel_jn bessel_y0 bessel_y1 bessel_yn bge bgt
|
56
|
+
bit_size ble blt btest c_associated c_f_pointer c_f_procpointer
|
57
|
+
c_funloc c_loc c_sizeof ceiling char cmplx command_argument_count
|
58
|
+
compiler_options compiler_version conjg cos cosh count cpu_time cshift
|
59
|
+
date_and_time dble digits dim dot_product dprod dshiftl dshiftr
|
60
|
+
eoshift epsilon erf erfc_scaled erfc execute_command_line exp exponent
|
61
|
+
extends_type_of findloc floor fraction gamma get_command_argument
|
62
|
+
get_command get_environment_variable huge hypot iachar iall iand iany
|
63
|
+
ibclr ibits ibset ichar ieee_class ieee_copy_sign ieee_get_flag
|
61
64
|
ieee_get_halting_mode ieee_get_rounding_mode ieee_get_status
|
62
65
|
ieee_get_underflow_mode ieee_is_finite ieee_is_nan ieee_is_normal
|
63
66
|
ieee_logb ieee_next_after ieee_rem ieee_rint ieee_scalb
|
@@ -124,9 +127,12 @@ module Rouge
|
|
124
127
|
rule %r{\*\*|//|==|/=|<=|>=|=>|[-+*/<>=%]}, Operator
|
125
128
|
rule /\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV|[A-Z]+)\./i, Operator::Word
|
126
129
|
|
127
|
-
#
|
128
|
-
#
|
130
|
+
# Special rules for two-word keywords and types.
|
131
|
+
# Note: "doubleprecision" is covered by the normal keyword rule.
|
129
132
|
rule /double\s+precision\b/i, Keyword::Type
|
133
|
+
rule /go\s+to\b/i, Keyword
|
134
|
+
rule /sync\s+(all|images|memory)\b/i, Keyword
|
135
|
+
rule /error\s+stop\b/i, Keyword
|
130
136
|
|
131
137
|
rule /#{name}/m do |m|
|
132
138
|
match = m[0].downcase
|
data/lib/rouge/lexers/igorpro.rb
CHANGED
@@ -19,6 +19,7 @@ module Rouge
|
|
19
19
|
break return continue
|
20
20
|
for endfor do while
|
21
21
|
case default
|
22
|
+
try catch endtry
|
22
23
|
abortonrte
|
23
24
|
)
|
24
25
|
end
|
@@ -247,12 +248,11 @@ module Rouge
|
|
247
248
|
end
|
248
249
|
|
249
250
|
def self.object_name
|
250
|
-
|
251
|
+
/\b[a-z][a-z0-9_\.]*?\b/i
|
251
252
|
end
|
252
253
|
|
253
254
|
object = self.object_name
|
254
|
-
|
255
|
-
noLineBreak = /[ \t]+/
|
255
|
+
noLineBreak = /(?:[ \t]|(?:\\\s*[\r\n]))+/
|
256
256
|
operator = %r([\#$~!%^&*+=\|?:<>/-])
|
257
257
|
punctuation = /[{}()\[\],.;]/
|
258
258
|
number_float= /0x[a-f0-9]+/i
|
@@ -262,7 +262,7 @@ module Rouge
|
|
262
262
|
state :root do
|
263
263
|
rule %r(//), Comment, :comments
|
264
264
|
|
265
|
-
rule
|
265
|
+
rule /#{object}/ do |m|
|
266
266
|
if m[0].downcase =~ /function/
|
267
267
|
token Keyword::Declaration
|
268
268
|
push :parse_function
|
@@ -281,8 +281,8 @@ module Rouge
|
|
281
281
|
elsif self.class.hdf5Operation.include? m[0].downcase
|
282
282
|
token Keyword::Reserved
|
283
283
|
push :operationFlags
|
284
|
-
elsif m[0].downcase =~
|
285
|
-
token Name::
|
284
|
+
elsif m[0].downcase =~ /\b(v|s|w)_[a-z]+[a-z0-9]*/
|
285
|
+
token Name::Constant
|
286
286
|
else
|
287
287
|
token Name
|
288
288
|
end
|
@@ -293,6 +293,7 @@ module Rouge
|
|
293
293
|
|
294
294
|
mixin :characters
|
295
295
|
mixin :numbers
|
296
|
+
mixin :whitespace
|
296
297
|
end
|
297
298
|
|
298
299
|
state :preprocessor do
|
@@ -310,7 +311,7 @@ module Rouge
|
|
310
311
|
|
311
312
|
state :assignment do
|
312
313
|
mixin :whitespace
|
313
|
-
rule /\"/,
|
314
|
+
rule /\"/, Literal::String::Double, :string1 #punctuation for string
|
314
315
|
mixin :string2
|
315
316
|
rule /#{number_float}/, Literal::Number::Float, :pop!
|
316
317
|
rule /#{number_int}/, Literal::Number::Integer, :pop!
|
@@ -322,11 +323,11 @@ module Rouge
|
|
322
323
|
state :parse_variables do
|
323
324
|
mixin :whitespace
|
324
325
|
rule /[=]/, Punctuation, :assignment
|
325
|
-
rule %r([/][a-z]+)i, Keyword::Pseudo, :parse_variables
|
326
326
|
rule object, Name::Variable
|
327
327
|
rule /[\[\]]/, Punctuation # optional variables in functions
|
328
328
|
rule /[,]/, Punctuation, :parse_variables
|
329
329
|
rule /\)/, Punctuation, :pop! # end of function
|
330
|
+
rule %r([/][a-z]+)i, Keyword::Pseudo, :parse_variables
|
330
331
|
rule(//) { pop! }
|
331
332
|
end
|
332
333
|
|
@@ -367,7 +368,7 @@ module Rouge
|
|
367
368
|
rule /\s/, Text
|
368
369
|
rule /#{operator}/, Operator
|
369
370
|
rule /#{punctuation}/, Punctuation
|
370
|
-
rule /\"/,
|
371
|
+
rule /\"/, Literal::String::Double, :string1 #punctuation for string
|
371
372
|
mixin :string2
|
372
373
|
end
|
373
374
|
|
@@ -387,7 +388,7 @@ module Rouge
|
|
387
388
|
rule /\\\"/, Literal::String::Escape
|
388
389
|
rule /\\/, Literal::String::Escape
|
389
390
|
rule /[^"]/, Literal::String
|
390
|
-
rule /\"/,
|
391
|
+
rule /\"/, Literal::String::Double, :pop! #punctuation for string
|
391
392
|
end
|
392
393
|
|
393
394
|
state :string2 do
|
@@ -198,12 +198,24 @@ module Rouge
|
|
198
198
|
rule /0o[0-7][0-7_]*/i, Num::Oct
|
199
199
|
rule /0b[01][01_]*/i, Num::Bin
|
200
200
|
rule /[0-9]+/, Num::Integer
|
201
|
-
|
202
|
-
rule /"
|
203
|
-
rule /'
|
201
|
+
|
202
|
+
rule /"/, Str::Double, :dq
|
203
|
+
rule /'/, Str::Single, :sq
|
204
204
|
rule /:/, Punctuation
|
205
205
|
end
|
206
206
|
|
207
|
+
state :dq do
|
208
|
+
rule /[^\\"]+/, Str::Double
|
209
|
+
rule /\\"/, Str::Escape
|
210
|
+
rule /"/, Str::Double, :pop!
|
211
|
+
end
|
212
|
+
|
213
|
+
state :sq do
|
214
|
+
rule /[^\\']+/, Str::Single
|
215
|
+
rule /\\'/, Str::Escape
|
216
|
+
rule /'/, Str::Single, :pop!
|
217
|
+
end
|
218
|
+
|
207
219
|
# braced parts that aren't object literals
|
208
220
|
state :statement do
|
209
221
|
rule /case\b/ do
|
data/lib/rouge/lexers/kotlin.rb
CHANGED
@@ -41,7 +41,7 @@ module Rouge
|
|
41
41
|
rule %r'"(\\\\|\\"|[^"\n])*["\n]'m, Str
|
42
42
|
rule %r"'\\.'|'[^\\]'", Str::Char
|
43
43
|
rule %r"[0-9](\.[0-9]+)?([eE][+-][0-9]+)?[flFL]?|0[xX][0-9a-fA-F]+[Ll]?", Num
|
44
|
-
rule %r'(
|
44
|
+
rule %r'(companion)(\s+)(object)' do
|
45
45
|
groups Keyword, Text, Keyword
|
46
46
|
end
|
47
47
|
rule %r'(class|data\s+class|interface|object)(\s+)' do
|
@@ -0,0 +1,205 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Nix < RegexLexer
|
6
|
+
title 'Nix'
|
7
|
+
desc 'The Nix expression language (https://nixos.org/nix/manual/#ch-expression-language)'
|
8
|
+
tag 'nix'
|
9
|
+
aliases 'nixos'
|
10
|
+
filenames '*.nix'
|
11
|
+
|
12
|
+
state :whitespaces do
|
13
|
+
rule /^\s*\n\s*$/m, Text
|
14
|
+
rule /\s+/, Text
|
15
|
+
end
|
16
|
+
|
17
|
+
state :comment do
|
18
|
+
rule /#.*$/, Comment
|
19
|
+
rule /\/\*/, Comment, :multiline_comment
|
20
|
+
end
|
21
|
+
|
22
|
+
state :multiline_comment do
|
23
|
+
rule /\*\//, Comment, :pop!
|
24
|
+
rule /./, Comment
|
25
|
+
end
|
26
|
+
|
27
|
+
state :number do
|
28
|
+
rule /[0-9]/, Num::Integer
|
29
|
+
end
|
30
|
+
|
31
|
+
state :null do
|
32
|
+
rule /(null)/, Keyword::Constant
|
33
|
+
end
|
34
|
+
|
35
|
+
state :boolean do
|
36
|
+
rule /(true|false)/, Keyword::Constant
|
37
|
+
end
|
38
|
+
|
39
|
+
state :binding do
|
40
|
+
rule /[a-zA-Z_][a-zA-Z0-9-]*/, Name::Variable
|
41
|
+
end
|
42
|
+
|
43
|
+
state :path do
|
44
|
+
word = "[a-zA-Z0-9\._-]+"
|
45
|
+
section = "(\/#{word})"
|
46
|
+
prefix = "[a-z\+]+:\/\/"
|
47
|
+
root = /#{section}+/.source
|
48
|
+
tilde = /~#{section}+/.source
|
49
|
+
basic = /#{word}(\/#{word})+/.source
|
50
|
+
url = /#{prefix}(\/?#{basic})/.source
|
51
|
+
rule /(#{root}|#{tilde}|#{basic}|#{url})/, Str::Other
|
52
|
+
end
|
53
|
+
|
54
|
+
state :string do
|
55
|
+
rule /"/, Str::Double, :string_double_quoted
|
56
|
+
rule /''/, Str::Double, :string_indented
|
57
|
+
end
|
58
|
+
|
59
|
+
state :string_content do
|
60
|
+
rule /\${/, Str::Interpol, :string_interpolated_arg
|
61
|
+
mixin :escaped_sequence
|
62
|
+
end
|
63
|
+
|
64
|
+
state :escaped_sequence do
|
65
|
+
rule /\\./, Str::Escape
|
66
|
+
end
|
67
|
+
|
68
|
+
state :string_interpolated_arg do
|
69
|
+
mixin :expression
|
70
|
+
rule /}/, Str::Interpol, :pop!
|
71
|
+
end
|
72
|
+
|
73
|
+
state :string_indented do
|
74
|
+
mixin :string_content
|
75
|
+
rule /''/, Str::Double, :pop!
|
76
|
+
rule /./, Str::Double
|
77
|
+
end
|
78
|
+
|
79
|
+
state :string_double_quoted do
|
80
|
+
mixin :string_content
|
81
|
+
rule /"/, Str::Double, :pop!
|
82
|
+
rule /./, Str::Double
|
83
|
+
end
|
84
|
+
|
85
|
+
state :operator do
|
86
|
+
rule /(\.|\?|\+\+|\+|!=|!|\/\/|\=\=|&&|\|\||->|\/|\*|-|<|>|<=|=>)/, Operator
|
87
|
+
end
|
88
|
+
|
89
|
+
state :assignment do
|
90
|
+
rule /(=)/, Operator
|
91
|
+
rule /(@)/, Operator
|
92
|
+
end
|
93
|
+
|
94
|
+
state :accessor do
|
95
|
+
rule /(\$)/, Punctuation
|
96
|
+
end
|
97
|
+
|
98
|
+
state :delimiter do
|
99
|
+
rule /(;|,|:)/, Punctuation
|
100
|
+
end
|
101
|
+
|
102
|
+
state :atom_content do
|
103
|
+
mixin :expression
|
104
|
+
rule /\)/, Punctuation, :pop!
|
105
|
+
end
|
106
|
+
|
107
|
+
state :atom do
|
108
|
+
rule /\(/, Punctuation, :atom_content
|
109
|
+
end
|
110
|
+
|
111
|
+
state :list do
|
112
|
+
rule /\[/, Punctuation, :list_content
|
113
|
+
end
|
114
|
+
|
115
|
+
state :list_content do
|
116
|
+
rule /\]/, Punctuation, :pop!
|
117
|
+
mixin :expression
|
118
|
+
end
|
119
|
+
|
120
|
+
state :set do
|
121
|
+
rule /{/, Punctuation, :set_content
|
122
|
+
end
|
123
|
+
|
124
|
+
state :set_content do
|
125
|
+
rule /}/, Punctuation, :pop!
|
126
|
+
mixin :expression
|
127
|
+
end
|
128
|
+
|
129
|
+
state :expression do
|
130
|
+
mixin :ignore
|
131
|
+
mixin :comment
|
132
|
+
mixin :boolean
|
133
|
+
mixin :null
|
134
|
+
mixin :number
|
135
|
+
mixin :path
|
136
|
+
mixin :string
|
137
|
+
mixin :keywords
|
138
|
+
mixin :operator
|
139
|
+
mixin :accessor
|
140
|
+
mixin :assignment
|
141
|
+
mixin :delimiter
|
142
|
+
mixin :binding
|
143
|
+
mixin :atom
|
144
|
+
mixin :set
|
145
|
+
mixin :list
|
146
|
+
end
|
147
|
+
|
148
|
+
state :keywords do
|
149
|
+
mixin :keywords_namespace
|
150
|
+
mixin :keywords_declaration
|
151
|
+
mixin :keywords_conditional
|
152
|
+
mixin :keywords_reserved
|
153
|
+
mixin :keywords_builtin
|
154
|
+
end
|
155
|
+
|
156
|
+
state :keywords_namespace do
|
157
|
+
keywords = %w(with in inherit)
|
158
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword::Namespace
|
159
|
+
end
|
160
|
+
|
161
|
+
state :keywords_declaration do
|
162
|
+
keywords = %w(let)
|
163
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword::Declaration
|
164
|
+
end
|
165
|
+
|
166
|
+
state :keywords_conditional do
|
167
|
+
keywords = %w(if then else)
|
168
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword
|
169
|
+
end
|
170
|
+
|
171
|
+
state :keywords_reserved do
|
172
|
+
keywords = %w(rec assert map)
|
173
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword::Reserved
|
174
|
+
end
|
175
|
+
|
176
|
+
state :keywords_builtin do
|
177
|
+
keywords = %w(
|
178
|
+
abort
|
179
|
+
baseNameOf
|
180
|
+
builtins
|
181
|
+
derivation
|
182
|
+
fetchTarball
|
183
|
+
import
|
184
|
+
isNull
|
185
|
+
removeAttrs
|
186
|
+
throw
|
187
|
+
toString
|
188
|
+
)
|
189
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword::Reserved
|
190
|
+
end
|
191
|
+
|
192
|
+
state :ignore do
|
193
|
+
mixin :whitespaces
|
194
|
+
end
|
195
|
+
|
196
|
+
state :root do
|
197
|
+
mixin :ignore
|
198
|
+
mixin :expression
|
199
|
+
end
|
200
|
+
|
201
|
+
start do
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
data/lib/rouge/lexers/q.rb
CHANGED
@@ -94,8 +94,11 @@ module Rouge
|
|
94
94
|
rule(%r{'|\/:|\\:|':|\\|\/|0:|1:|2:}, Operator)
|
95
95
|
|
96
96
|
## numbers
|
97
|
-
rule(/(
|
98
|
-
rule(
|
97
|
+
rule(/(\d+[.]\d*|[.]\d+)(e[+-]?\d+)?[ef]?/, Num::Float)
|
98
|
+
rule(/\d+e[+-]?\d+[ef]?/, Num::Float)
|
99
|
+
rule(/\d+[ef]/, Num::Float)
|
100
|
+
rule(/0x[0-9a-f]+/i, Num::Hex)
|
101
|
+
rule(/[01]+b/, Num::Bin)
|
99
102
|
rule(/[0-9]+[hij]?/, Num::Integer)
|
100
103
|
## symbols and paths
|
101
104
|
rule(%r{(`:[:a-z0-9._\/]*|`(?:[a-z0-9.][:a-z0-9._]*)?)}i, Str::Symbol)
|
data/lib/rouge/text_analyzer.rb
CHANGED
@@ -15,6 +15,7 @@ module Rouge
|
|
15
15
|
# This normalizes things so that `text.shebang?('bash')` will detect
|
16
16
|
# `#!/bash`, '#!/bin/bash', '#!/usr/bin/env bash', and '#!/bin/bash -x'
|
17
17
|
def shebang?(match)
|
18
|
+
return false unless shebang
|
18
19
|
match = /\b#{match}(\s|$)/
|
19
20
|
match === shebang
|
20
21
|
end
|
data/lib/rouge/version.rb
CHANGED
data/rouge.gemspec
CHANGED
@@ -14,5 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rubyforge_project = "rouge"
|
15
15
|
s.files = Dir['Gemfile', 'LICENSE', 'rouge.gemspec', 'lib/**/*.rb', 'lib/**/*.yml', 'bin/rougify', 'lib/rouge/demos/*']
|
16
16
|
s.executables = %w(rougify)
|
17
|
-
s.
|
17
|
+
s.licenses = ['MIT', 'BSD-2-Clause']
|
18
|
+
|
19
|
+
s.add_development_dependency "bundler", "~> 1.10"
|
20
|
+
s.add_development_dependency "rake", "~> 12.0"
|
18
21
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.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: 2017-
|
12
|
-
dependencies:
|
11
|
+
date: 2017-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.0'
|
13
41
|
description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
|
14
42
|
email:
|
15
43
|
- jneen@jneen.net
|
@@ -99,6 +127,7 @@ files:
|
|
99
127
|
- lib/rouge/demos/nasm
|
100
128
|
- lib/rouge/demos/nginx
|
101
129
|
- lib/rouge/demos/nim
|
130
|
+
- lib/rouge/demos/nix
|
102
131
|
- lib/rouge/demos/objective_c
|
103
132
|
- lib/rouge/demos/ocaml
|
104
133
|
- lib/rouge/demos/pascal
|
@@ -248,6 +277,7 @@ files:
|
|
248
277
|
- lib/rouge/lexers/nasm.rb
|
249
278
|
- lib/rouge/lexers/nginx.rb
|
250
279
|
- lib/rouge/lexers/nim.rb
|
280
|
+
- lib/rouge/lexers/nix.rb
|
251
281
|
- lib/rouge/lexers/objective_c.rb
|
252
282
|
- lib/rouge/lexers/ocaml.rb
|
253
283
|
- lib/rouge/lexers/pascal.rb
|
@@ -327,7 +357,8 @@ files:
|
|
327
357
|
- rouge.gemspec
|
328
358
|
homepage: http://rouge.jneen.net/
|
329
359
|
licenses:
|
330
|
-
- MIT
|
360
|
+
- MIT
|
361
|
+
- BSD-2-Clause
|
331
362
|
metadata: {}
|
332
363
|
post_install_message:
|
333
364
|
rdoc_options: []
|