rouge 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge.rb +3 -0
- data/lib/rouge/cli.rb +19 -2
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/tex.rb +90 -0
- data/lib/rouge/guessers/glob_mapping.rb +1 -1
- data/lib/rouge/lexer.rb +22 -10
- data/lib/rouge/lexers/abap.rb +11 -11
- data/lib/rouge/lexers/actionscript.rb +34 -34
- data/lib/rouge/lexers/apache.rb +8 -8
- data/lib/rouge/lexers/apple_script.rb +15 -14
- data/lib/rouge/lexers/awk.rb +25 -25
- data/lib/rouge/lexers/biml.rb +4 -4
- data/lib/rouge/lexers/bpf.rb +104 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +12 -12
- data/lib/rouge/lexers/c.rb +30 -30
- data/lib/rouge/lexers/ceylon.rb +1 -29
- data/lib/rouge/lexers/cfscript.rb +26 -26
- data/lib/rouge/lexers/clojure.rb +14 -14
- data/lib/rouge/lexers/cmake.rb +14 -14
- data/lib/rouge/lexers/coffeescript.rb +30 -30
- data/lib/rouge/lexers/common_lisp.rb +36 -36
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/coq.rb +18 -18
- data/lib/rouge/lexers/cpp.rb +8 -8
- data/lib/rouge/lexers/crystal.rb +70 -70
- data/lib/rouge/lexers/csharp.rb +28 -28
- data/lib/rouge/lexers/css.rb +23 -23
- data/lib/rouge/lexers/d.rb +59 -59
- data/lib/rouge/lexers/dart.rb +33 -33
- data/lib/rouge/lexers/digdag.rb +1 -1
- data/lib/rouge/lexers/docker.rb +10 -10
- data/lib/rouge/lexers/dot.rb +16 -16
- data/lib/rouge/lexers/eiffel.rb +20 -20
- data/lib/rouge/lexers/elixir.rb +29 -28
- data/lib/rouge/lexers/elm.rb +29 -29
- data/lib/rouge/lexers/erb.rb +4 -4
- data/lib/rouge/lexers/factor.rb +40 -40
- data/lib/rouge/lexers/fortran.rb +32 -32
- data/lib/rouge/lexers/fsharp.rb +26 -26
- data/lib/rouge/lexers/gherkin.rb +13 -13
- data/lib/rouge/lexers/glsl.rb +0 -4
- data/lib/rouge/lexers/go.rb +1 -1
- data/lib/rouge/lexers/graphql.rb +62 -62
- data/lib/rouge/lexers/groovy.rb +23 -25
- data/lib/rouge/lexers/hack.rb +1 -1
- data/lib/rouge/lexers/haml.rb +25 -29
- data/lib/rouge/lexers/handlebars.rb +18 -18
- data/lib/rouge/lexers/haskell.rb +66 -65
- data/lib/rouge/lexers/hcl.rb +25 -25
- data/lib/rouge/lexers/html.rb +31 -31
- data/lib/rouge/lexers/http.rb +4 -4
- data/lib/rouge/lexers/hylang.rb +14 -14
- data/lib/rouge/lexers/idlang.rb +32 -32
- data/lib/rouge/lexers/igorpro.rb +30 -30
- data/lib/rouge/lexers/ini.rb +12 -12
- data/lib/rouge/lexers/io.rb +7 -7
- data/lib/rouge/lexers/irb.rb +5 -5
- data/lib/rouge/lexers/java.rb +24 -24
- data/lib/rouge/lexers/javascript.rb +51 -51
- data/lib/rouge/lexers/jinja.rb +22 -22
- data/lib/rouge/lexers/json.rb +11 -10
- data/lib/rouge/lexers/json_doc.rb +2 -2
- data/lib/rouge/lexers/jsonnet.rb +18 -18
- data/lib/rouge/lexers/jsp.rb +28 -28
- data/lib/rouge/lexers/jsx.rb +16 -16
- data/lib/rouge/lexers/julia.rb +44 -44
- data/lib/rouge/lexers/kotlin.rb +3 -3
- data/lib/rouge/lexers/lasso.rb +50 -50
- data/lib/rouge/lexers/liquid.rb +53 -53
- data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +23 -16
- data/lib/rouge/lexers/lua.rb +3 -3
- data/lib/rouge/lexers/m68k.rb +18 -19
- data/lib/rouge/lexers/magik.rb +126 -0
- data/lib/rouge/lexers/make.rb +22 -28
- data/lib/rouge/lexers/markdown.rb +37 -37
- data/lib/rouge/lexers/mathematica.rb +11 -11
- data/lib/rouge/lexers/matlab.rb +20 -20
- data/lib/rouge/lexers/moonscript.rb +3 -3
- data/lib/rouge/lexers/mosel.rb +17 -17
- data/lib/rouge/lexers/mxml.rb +18 -18
- data/lib/rouge/lexers/nasm.rb +24 -25
- data/lib/rouge/lexers/nginx.rb +14 -14
- data/lib/rouge/lexers/nim.rb +1 -1
- data/lib/rouge/lexers/nix.rb +42 -42
- data/lib/rouge/lexers/objective_c.rb +38 -38
- data/lib/rouge/lexers/ocaml.rb +29 -29
- data/lib/rouge/lexers/pascal.rb +4 -4
- data/lib/rouge/lexers/perl.rb +68 -68
- data/lib/rouge/lexers/php.rb +38 -38
- data/lib/rouge/lexers/plist.rb +14 -14
- data/lib/rouge/lexers/pony.rb +19 -19
- data/lib/rouge/lexers/powershell.rb +25 -25
- data/lib/rouge/lexers/praat.rb +75 -75
- data/lib/rouge/lexers/prolog.rb +26 -20
- data/lib/rouge/lexers/prometheus.rb +30 -30
- data/lib/rouge/lexers/properties.rb +12 -12
- data/lib/rouge/lexers/protobuf.rb +22 -22
- data/lib/rouge/lexers/puppet.rb +31 -31
- data/lib/rouge/lexers/python.rb +52 -52
- data/lib/rouge/lexers/q.rb +12 -12
- data/lib/rouge/lexers/qml.rb +12 -12
- data/lib/rouge/lexers/r.rb +12 -12
- data/lib/rouge/lexers/racket.rb +22 -22
- data/lib/rouge/lexers/ruby.rb +71 -69
- data/lib/rouge/lexers/rust.rb +30 -30
- data/lib/rouge/lexers/sass.rb +8 -8
- data/lib/rouge/lexers/sass/common.rb +40 -40
- data/lib/rouge/lexers/scala.rb +43 -43
- data/lib/rouge/lexers/scheme.rb +18 -18
- data/lib/rouge/lexers/scss.rb +3 -3
- data/lib/rouge/lexers/sed.rb +29 -29
- data/lib/rouge/lexers/shell.rb +61 -52
- data/lib/rouge/lexers/sieve.rb +8 -8
- data/lib/rouge/lexers/slim.rb +24 -24
- data/lib/rouge/lexers/smalltalk.rb +33 -33
- data/lib/rouge/lexers/smarty.rb +12 -12
- data/lib/rouge/lexers/sml.rb +67 -67
- data/lib/rouge/lexers/sqf.rb +1 -1
- data/lib/rouge/lexers/sql.rb +21 -21
- data/lib/rouge/lexers/supercollider.rb +19 -19
- data/lib/rouge/lexers/swift.rb +42 -39
- data/lib/rouge/lexers/tap.rb +20 -20
- data/lib/rouge/lexers/tcl.rb +27 -27
- data/lib/rouge/lexers/terraform.rb +13 -13
- data/lib/rouge/lexers/tex.rb +19 -19
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/tulip.rb +36 -36
- data/lib/rouge/lexers/turtle.rb +35 -38
- data/lib/rouge/lexers/vala.rb +17 -17
- data/lib/rouge/lexers/vb.rb +27 -27
- data/lib/rouge/lexers/verilog.rb +25 -27
- data/lib/rouge/lexers/vhdl.rb +10 -10
- data/lib/rouge/lexers/viml.rb +14 -14
- data/lib/rouge/lexers/vue.rb +9 -9
- data/lib/rouge/lexers/wollok.rb +25 -25
- data/lib/rouge/lexers/xml.rb +17 -21
- data/lib/rouge/lexers/xojo.rb +15 -15
- data/lib/rouge/lexers/yaml.rb +61 -61
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/tex_theme_renderer.rb +128 -0
- data/lib/rouge/theme.rb +4 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/version.rb +1 -1
- metadata +11 -2
data/lib/rouge/lexers/csharp.rb
CHANGED
@@ -43,58 +43,58 @@ module Rouge
|
|
43
43
|
)
|
44
44
|
|
45
45
|
state :whitespace do
|
46
|
-
rule /\s+/m, Text
|
46
|
+
rule %r/\s+/m, Text
|
47
47
|
rule %r(//.*?$), Comment::Single
|
48
48
|
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
49
49
|
end
|
50
50
|
|
51
51
|
state :nest do
|
52
|
-
rule /{/, Punctuation, :nest
|
53
|
-
rule /}/, Punctuation, :pop!
|
52
|
+
rule %r/{/, Punctuation, :nest
|
53
|
+
rule %r/}/, Punctuation, :pop!
|
54
54
|
mixin :root
|
55
55
|
end
|
56
56
|
|
57
57
|
state :splice_string do
|
58
|
-
rule /\\./, Str
|
59
|
-
rule /{/, Punctuation, :nest
|
60
|
-
rule /"|\n/, Str, :pop!
|
61
|
-
rule /./, Str
|
58
|
+
rule %r/\\./, Str
|
59
|
+
rule %r/{/, Punctuation, :nest
|
60
|
+
rule %r/"|\n/, Str, :pop!
|
61
|
+
rule %r/./, Str
|
62
62
|
end
|
63
63
|
|
64
64
|
state :splice_literal do
|
65
|
-
rule /""/, Str
|
66
|
-
rule /{/, Punctuation, :nest
|
67
|
-
rule /"/, Str, :pop!
|
68
|
-
rule /./, Str
|
65
|
+
rule %r/""/, Str
|
66
|
+
rule %r/{/, Punctuation, :nest
|
67
|
+
rule %r/"/, Str, :pop!
|
68
|
+
rule %r/./, Str
|
69
69
|
end
|
70
70
|
|
71
71
|
state :root do
|
72
72
|
mixin :whitespace
|
73
73
|
|
74
|
-
rule /[$]\s*"/, Str, :splice_string
|
75
|
-
rule /[$]@\s*"/, Str, :splice_literal
|
74
|
+
rule %r/[$]\s*"/, Str, :splice_string
|
75
|
+
rule %r/[$]@\s*"/, Str, :splice_literal
|
76
76
|
|
77
|
-
rule /(<\[)\s*(#{id}:)?/, Keyword
|
78
|
-
rule /\]>/, Keyword
|
77
|
+
rule %r/(<\[)\s*(#{id}:)?/, Keyword
|
78
|
+
rule %r/\]>/, Keyword
|
79
79
|
|
80
|
-
rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
|
81
|
-
rule /@"(""|[^"])*"/m, Str
|
82
|
-
rule /"(\\.|.)*?["\n]/, Str
|
83
|
-
rule /'(\\.|.)'/, Str::Char
|
84
|
-
rule /0x[0-9a-f]+[lu]?/i, Num
|
80
|
+
rule %r/[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
|
81
|
+
rule %r/@"(""|[^"])*"/m, Str
|
82
|
+
rule %r/"(\\.|.)*?["\n]/, Str
|
83
|
+
rule %r/'(\\.|.)'/, Str::Char
|
84
|
+
rule %r/0x[0-9a-f]+[lu]?/i, Num
|
85
85
|
rule %r(
|
86
86
|
[0-9]
|
87
87
|
([.][0-9]*)? # decimal
|
88
88
|
(e[+-][0-9]+)? # exponent
|
89
89
|
[fldu]? # type
|
90
90
|
)ix, Num
|
91
|
-
rule /\b(?:class|struct|interface)\b/, Keyword, :class
|
92
|
-
rule /\b(?:namespace|using)\b/, Keyword, :namespace
|
93
|
-
rule /^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
|
91
|
+
rule %r/\b(?:class|struct|interface)\b/, Keyword, :class
|
92
|
+
rule %r/\b(?:namespace|using)\b/, Keyword, :namespace
|
93
|
+
rule %r/^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
|
94
94
|
Comment::Preproc
|
95
|
-
rule /\b(#{keywords.join('|')})\b/, Keyword
|
96
|
-
rule /\b(#{keywords_type.join('|')})\b/, Keyword::Type
|
97
|
-
rule /#{id}(?=\s*[(])/, Name::Function
|
95
|
+
rule %r/\b(#{keywords.join('|')})\b/, Keyword
|
96
|
+
rule %r/\b(#{keywords_type.join('|')})\b/, Keyword::Type
|
97
|
+
rule %r/#{id}(?=\s*[(])/, Name::Function
|
98
98
|
rule id, Name
|
99
99
|
end
|
100
100
|
|
@@ -105,8 +105,8 @@ module Rouge
|
|
105
105
|
|
106
106
|
state :namespace do
|
107
107
|
mixin :whitespace
|
108
|
-
rule /(?=[(])/, Text, :pop!
|
109
|
-
rule /(#{id}|[.])+/, Name::Namespace, :pop!
|
108
|
+
rule %r/(?=[(])/, Text, :pop!
|
109
|
+
rule %r/(#{id}|[.])+/, Name::Namespace, :pop!
|
110
110
|
end
|
111
111
|
|
112
112
|
end
|
data/lib/rouge/lexers/css.rb
CHANGED
@@ -185,25 +185,25 @@ module Rouge
|
|
185
185
|
|
186
186
|
state :root do
|
187
187
|
mixin :basics
|
188
|
-
rule /{/, Punctuation, :stanza
|
189
|
-
rule /:[:]?#{identifier}/, Name::Decorator
|
190
|
-
rule /\.#{identifier}/, Name::Class
|
191
|
-
rule /##{identifier}/, Name::Function
|
192
|
-
rule /@#{identifier}/, Keyword, :at_rule
|
188
|
+
rule %r/{/, Punctuation, :stanza
|
189
|
+
rule %r/:[:]?#{identifier}/, Name::Decorator
|
190
|
+
rule %r/\.#{identifier}/, Name::Class
|
191
|
+
rule %r/##{identifier}/, Name::Function
|
192
|
+
rule %r/@#{identifier}/, Keyword, :at_rule
|
193
193
|
rule identifier, Name::Tag
|
194
194
|
rule %r([~^*!%&\[\]()<>|+=@:;,./?-]), Operator
|
195
|
-
rule /"(\\\\|\\"|[^"])*"/, Str::Single
|
196
|
-
rule /'(\\\\|\\'|[^'])*'/, Str::Double
|
195
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Str::Single
|
196
|
+
rule %r/'(\\\\|\\'|[^'])*'/, Str::Double
|
197
197
|
end
|
198
198
|
|
199
199
|
state :value do
|
200
200
|
mixin :basics
|
201
|
-
rule /url\(.*?\)/, Str::Other
|
202
|
-
rule /#[0-9a-f]{1,6}/i, Num # colors
|
203
|
-
rule /#{number}(?:%|(?:em|px|pt|pc|in|mm|cm|ex|rem|ch|vw|vh|vmin|vmax|dpi|dpcm|dppx|deg|grad|rad|turn|s|ms|Hz|kHz)\b)?/, Num
|
204
|
-
rule /[\[\]():\/.,]/, Punctuation
|
205
|
-
rule /"(\\\\|\\"|[^"])*"/, Str::Single
|
206
|
-
rule /'(\\\\|\\'|[^'])*'/, Str::Double
|
201
|
+
rule %r/url\(.*?\)/, Str::Other
|
202
|
+
rule %r/#[0-9a-f]{1,6}/i, Num # colors
|
203
|
+
rule %r/#{number}(?:%|(?:em|px|pt|pc|in|mm|cm|ex|rem|ch|vw|vh|vmin|vmax|dpi|dpcm|dppx|deg|grad|rad|turn|s|ms|Hz|kHz)\b)?/, Num
|
204
|
+
rule %r/[\[\]():\/.,]/, Punctuation
|
205
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Str::Single
|
206
|
+
rule %r/'(\\\\|\\'|[^'])*'/, Str::Double
|
207
207
|
rule(identifier) do |m|
|
208
208
|
if self.class.constants.include? m[0]
|
209
209
|
token Name::Constant
|
@@ -216,9 +216,9 @@ module Rouge
|
|
216
216
|
end
|
217
217
|
|
218
218
|
state :at_rule do
|
219
|
-
rule /{(?=\s*#{identifier}\s*:)/m, Punctuation, :at_stanza
|
220
|
-
rule /{/, Punctuation, :at_body
|
221
|
-
rule /;/, Punctuation, :pop!
|
219
|
+
rule %r/{(?=\s*#{identifier}\s*:)/m, Punctuation, :at_stanza
|
220
|
+
rule %r/{/, Punctuation, :at_body
|
221
|
+
rule %r/;/, Punctuation, :pop!
|
222
222
|
mixin :value
|
223
223
|
end
|
224
224
|
|
@@ -233,21 +233,21 @@ module Rouge
|
|
233
233
|
end
|
234
234
|
|
235
235
|
state :at_content do
|
236
|
-
rule /}/ do
|
236
|
+
rule %r/}/ do
|
237
237
|
token Punctuation
|
238
238
|
pop! 2
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
242
|
state :basics do
|
243
|
-
rule /\s+/m, Text
|
243
|
+
rule %r/\s+/m, Text
|
244
244
|
rule %r(/\*(?:.*?)\*/)m, Comment
|
245
245
|
end
|
246
246
|
|
247
247
|
state :stanza do
|
248
248
|
mixin :basics
|
249
|
-
rule /}/, Punctuation, :pop!
|
250
|
-
rule /(#{identifier})(\s*)(:)/m do |m|
|
249
|
+
rule %r/}/, Punctuation, :pop!
|
250
|
+
rule %r/(#{identifier})(\s*)(:)/m do |m|
|
251
251
|
name_tok = if self.class.attributes.include? m[1]
|
252
252
|
Name::Label
|
253
253
|
elsif self.class.vendor_prefixes.any? { |p| m[1].start_with?(p) }
|
@@ -263,10 +263,10 @@ module Rouge
|
|
263
263
|
end
|
264
264
|
|
265
265
|
state :stanza_value do
|
266
|
-
rule /;/, Punctuation, :pop!
|
266
|
+
rule %r/;/, Punctuation, :pop!
|
267
267
|
rule(/(?=})/) { pop! }
|
268
|
-
rule /!\s*important\b/, Comment::Preproc
|
269
|
-
rule /^@.*?$/, Comment::Preproc
|
268
|
+
rule %r/!\s*important\b/, Comment::Preproc
|
269
|
+
rule %r/^@.*?$/, Comment::Preproc
|
270
270
|
mixin :value
|
271
271
|
end
|
272
272
|
end
|
data/lib/rouge/lexers/d.rb
CHANGED
@@ -41,8 +41,8 @@ module Rouge
|
|
41
41
|
)
|
42
42
|
|
43
43
|
state :whitespace do
|
44
|
-
rule /\n/m, Text
|
45
|
-
rule /\s+/m, Text
|
44
|
+
rule %r/\n/m, Text
|
45
|
+
rule %r/\s+/m, Text
|
46
46
|
end
|
47
47
|
|
48
48
|
state :root do
|
@@ -52,58 +52,58 @@ module Rouge
|
|
52
52
|
rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/), Comment::Multiline
|
53
53
|
rule %r(/\+), Comment::Multiline, :nested_comment
|
54
54
|
# Keywords
|
55
|
-
rule /(#{keywords.join('|')})\b/, Keyword
|
56
|
-
rule /(#{keywords_type.join('|')})\b/, Keyword::Type
|
57
|
-
rule /(false|true|null)\b/, Keyword::Constant
|
58
|
-
rule /(#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo
|
59
|
-
rule /macro\b/, Keyword::Reserved
|
60
|
-
rule /(string|wstring|dstring|size_t|ptrdiff_t)\b/, Name::Builtin
|
55
|
+
rule %r/(#{keywords.join('|')})\b/, Keyword
|
56
|
+
rule %r/(#{keywords_type.join('|')})\b/, Keyword::Type
|
57
|
+
rule %r/(false|true|null)\b/, Keyword::Constant
|
58
|
+
rule %r/(#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo
|
59
|
+
rule %r/macro\b/, Keyword::Reserved
|
60
|
+
rule %r/(string|wstring|dstring|size_t|ptrdiff_t)\b/, Name::Builtin
|
61
61
|
# Literals
|
62
62
|
# HexFloat
|
63
|
-
rule /0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float
|
63
|
+
rule %r/0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float
|
64
64
|
# DecimalFloat
|
65
|
-
rule /[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float
|
66
|
-
rule /\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float
|
65
|
+
rule %r/[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float
|
66
|
+
rule %r/\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float
|
67
67
|
# IntegerLiteral
|
68
68
|
# Binary
|
69
|
-
rule /0[Bb][01_]+/, Num::Bin
|
69
|
+
rule %r/0[Bb][01_]+/, Num::Bin
|
70
70
|
# Octal
|
71
71
|
# TODO: 0[0-7] isn't supported use octal![0-7] instead
|
72
|
-
rule /0[0-7_]+/, Num::Oct
|
72
|
+
rule %r/0[0-7_]+/, Num::Oct
|
73
73
|
# Hexadecimal
|
74
|
-
rule /0[xX][0-9a-fA-F_]+/, Num::Hex
|
74
|
+
rule %r/0[xX][0-9a-fA-F_]+/, Num::Hex
|
75
75
|
# Decimal
|
76
|
-
rule /(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer
|
76
|
+
rule %r/(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer
|
77
77
|
# CharacterLiteral
|
78
|
-
rule /'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'/, Str::Char
|
78
|
+
rule %r/'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'/, Str::Char
|
79
79
|
# StringLiteral
|
80
80
|
# WysiwygString
|
81
|
-
rule /r"[^"]*"[cwd]?/, Str
|
81
|
+
rule %r/r"[^"]*"[cwd]?/, Str
|
82
82
|
# Alternate WysiwygString
|
83
|
-
rule /`[^`]*`[cwd]?/, Str
|
83
|
+
rule %r/`[^`]*`[cwd]?/, Str
|
84
84
|
# DoubleQuotedString
|
85
|
-
rule /"(\\\\|\\"|[^"])*"[cwd]?/, Str
|
85
|
+
rule %r/"(\\\\|\\"|[^"])*"[cwd]?/, Str
|
86
86
|
# EscapeSequence
|
87
|
-
rule /\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)/, Str
|
87
|
+
rule %r/\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)/, Str
|
88
88
|
# HexString
|
89
|
-
rule /x"[0-9a-fA-F_\s]*"[cwd]?/, Str
|
89
|
+
rule %r/x"[0-9a-fA-F_\s]*"[cwd]?/, Str
|
90
90
|
# DelimitedString
|
91
|
-
rule /q"\[/, Str, :delimited_bracket
|
92
|
-
rule /q"\(/, Str, :delimited_parenthesis
|
93
|
-
rule /q"</, Str, :delimited_angle
|
94
|
-
rule /q"\{/, Str, :delimited_curly
|
95
|
-
rule /q"([a-zA-Z_]\w*)\n.*?\n\1"/, Str
|
96
|
-
rule /q"(.).*?\1"/, Str
|
91
|
+
rule %r/q"\[/, Str, :delimited_bracket
|
92
|
+
rule %r/q"\(/, Str, :delimited_parenthesis
|
93
|
+
rule %r/q"</, Str, :delimited_angle
|
94
|
+
rule %r/q"\{/, Str, :delimited_curly
|
95
|
+
rule %r/q"([a-zA-Z_]\w*)\n.*?\n\1"/, Str
|
96
|
+
rule %r/q"(.).*?\1"/, Str
|
97
97
|
# TokenString
|
98
|
-
rule /q\{/, Str, :token_string
|
98
|
+
rule %r/q\{/, Str, :token_string
|
99
99
|
# Attributes
|
100
|
-
rule /@([a-zA-Z_]\w*)?/, Name::Decorator
|
100
|
+
rule %r/@([a-zA-Z_]\w*)?/, Name::Decorator
|
101
101
|
# Tokens
|
102
102
|
rule %r`(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>=|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]`, Punctuation
|
103
103
|
# Identifier
|
104
|
-
rule /[a-zA-Z_]\w*/, Name
|
104
|
+
rule %r/[a-zA-Z_]\w*/, Name
|
105
105
|
# Line
|
106
|
-
rule /#line\s.*\n/, Comment::Special
|
106
|
+
rule %r/#line\s.*\n/, Comment::Special
|
107
107
|
end
|
108
108
|
|
109
109
|
state :nested_comment do
|
@@ -114,63 +114,63 @@ module Rouge
|
|
114
114
|
end
|
115
115
|
|
116
116
|
state :token_string do
|
117
|
-
rule /\{/, Punctuation, :token_string_nest
|
118
|
-
rule /\}/, Str, :pop!
|
117
|
+
rule %r/\{/, Punctuation, :token_string_nest
|
118
|
+
rule %r/\}/, Str, :pop!
|
119
119
|
mixin :root
|
120
120
|
end
|
121
121
|
|
122
122
|
state :token_string_nest do
|
123
|
-
rule /\{/, Punctuation, :push
|
124
|
-
rule /\}/, Punctuation, :pop!
|
123
|
+
rule %r/\{/, Punctuation, :push
|
124
|
+
rule %r/\}/, Punctuation, :pop!
|
125
125
|
mixin :root
|
126
126
|
end
|
127
127
|
|
128
128
|
state :delimited_bracket do
|
129
|
-
rule /[^\[\]]+/, Str
|
130
|
-
rule /\[/, Str, :delimited_inside_bracket
|
131
|
-
rule /\]"/, Str, :pop!
|
129
|
+
rule %r/[^\[\]]+/, Str
|
130
|
+
rule %r/\[/, Str, :delimited_inside_bracket
|
131
|
+
rule %r/\]"/, Str, :pop!
|
132
132
|
end
|
133
133
|
|
134
134
|
state :delimited_inside_bracket do
|
135
|
-
rule /[^\[\]]+/, Str
|
136
|
-
rule /\[/, Str, :push
|
137
|
-
rule /\]/, Str, :pop!
|
135
|
+
rule %r/[^\[\]]+/, Str
|
136
|
+
rule %r/\[/, Str, :push
|
137
|
+
rule %r/\]/, Str, :pop!
|
138
138
|
end
|
139
139
|
|
140
140
|
state :delimited_parenthesis do
|
141
|
-
rule /[^()]+/, Str
|
142
|
-
rule /\(/, Str, :delimited_inside_parenthesis
|
143
|
-
rule /\)"/, Str, :pop!
|
141
|
+
rule %r/[^()]+/, Str
|
142
|
+
rule %r/\(/, Str, :delimited_inside_parenthesis
|
143
|
+
rule %r/\)"/, Str, :pop!
|
144
144
|
end
|
145
145
|
|
146
146
|
state :delimited_inside_parenthesis do
|
147
|
-
rule /[^()]+/, Str
|
148
|
-
rule /\(/, Str, :push
|
149
|
-
rule /\)/, Str, :pop!
|
147
|
+
rule %r/[^()]+/, Str
|
148
|
+
rule %r/\(/, Str, :push
|
149
|
+
rule %r/\)/, Str, :pop!
|
150
150
|
end
|
151
151
|
|
152
152
|
state :delimited_angle do
|
153
|
-
rule /[^<>]+/, Str
|
154
|
-
rule /</, Str, :delimited_inside_angle
|
155
|
-
rule />"/, Str, :pop!
|
153
|
+
rule %r/[^<>]+/, Str
|
154
|
+
rule %r/</, Str, :delimited_inside_angle
|
155
|
+
rule %r/>"/, Str, :pop!
|
156
156
|
end
|
157
157
|
|
158
158
|
state :delimited_inside_angle do
|
159
|
-
rule /[^<>]+/, Str
|
160
|
-
rule /</, Str, :push
|
161
|
-
rule />/, Str, :pop!
|
159
|
+
rule %r/[^<>]+/, Str
|
160
|
+
rule %r/</, Str, :push
|
161
|
+
rule %r/>/, Str, :pop!
|
162
162
|
end
|
163
163
|
|
164
164
|
state :delimited_curly do
|
165
|
-
rule /[^{}]+/, Str
|
166
|
-
rule /\{/, Str, :delimited_inside_curly
|
167
|
-
rule /\}"/, Str, :pop!
|
165
|
+
rule %r/[^{}]+/, Str
|
166
|
+
rule %r/\{/, Str, :delimited_inside_curly
|
167
|
+
rule %r/\}"/, Str, :pop!
|
168
168
|
end
|
169
169
|
|
170
170
|
state :delimited_inside_curly do
|
171
|
-
rule /[^{}]+/, Str
|
172
|
-
rule /\{/, Str, :push
|
173
|
-
rule /\}/, Str, :pop!
|
171
|
+
rule %r/[^{}]+/, Str
|
172
|
+
rule %r/\{/, Str, :push
|
173
|
+
rule %r/\}/, Str, :pop!
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
data/lib/rouge/lexers/dart.rb
CHANGED
@@ -30,8 +30,8 @@ module Rouge
|
|
30
30
|
state :root do
|
31
31
|
rule %r(^
|
32
32
|
(\s*(?:[a-zA-Z_][a-zA-Z\d_.\[\]]*\s+)+?) # return arguments
|
33
|
-
([a-zA-Z_]
|
34
|
-
(\s*)(\()
|
33
|
+
([a-zA-Z_]\w*) # method name
|
34
|
+
(\s*)(\() # signature start
|
35
35
|
)mx do |m|
|
36
36
|
# TODO: do this better, this shouldn't need a delegation
|
37
37
|
delegate Dart, m[1]
|
@@ -40,65 +40,65 @@ module Rouge
|
|
40
40
|
token Punctuation, m[4]
|
41
41
|
end
|
42
42
|
|
43
|
-
rule /\s+/, Text
|
43
|
+
rule %r/\s+/, Text
|
44
44
|
rule %r(//.*?$), Comment::Single
|
45
45
|
rule %r(/\*.*?\*/)m, Comment::Multiline
|
46
|
-
rule /"/, Str, :dqs
|
47
|
-
rule /'/, Str, :sqs
|
48
|
-
rule /r"[^"]*"/, Str::Other
|
49
|
-
rule /r'[^']*'/, Str::Other
|
50
|
-
rule /##{id}*/i, Str::Symbol
|
51
|
-
rule /@#{id}/, Name::Decorator
|
52
|
-
rule /(?:#{keywords.join('|')})\b/, Keyword
|
53
|
-
rule /(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
54
|
-
rule /(?:#{types.join('|')})\b/, Keyword::Type
|
55
|
-
rule /(?:true|false|null)\b/, Keyword::Constant
|
56
|
-
rule /(?:class|interface)\b/, Keyword::Declaration, :class
|
57
|
-
rule /(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
|
58
|
-
rule /(\.)(#{id})/ do
|
46
|
+
rule %r/"/, Str, :dqs
|
47
|
+
rule %r/'/, Str, :sqs
|
48
|
+
rule %r/r"[^"]*"/, Str::Other
|
49
|
+
rule %r/r'[^']*'/, Str::Other
|
50
|
+
rule %r/##{id}*/i, Str::Symbol
|
51
|
+
rule %r/@#{id}/, Name::Decorator
|
52
|
+
rule %r/(?:#{keywords.join('|')})\b/, Keyword
|
53
|
+
rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
54
|
+
rule %r/(?:#{types.join('|')})\b/, Keyword::Type
|
55
|
+
rule %r/(?:true|false|null)\b/, Keyword::Constant
|
56
|
+
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
|
57
|
+
rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
|
58
|
+
rule %r/(\.)(#{id})/ do
|
59
59
|
groups Operator, Name::Attribute
|
60
60
|
end
|
61
61
|
|
62
|
-
rule /#{id}:/, Name::Label
|
63
|
-
rule /\$?#{id}/, Name
|
64
|
-
rule /[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
|
65
|
-
rule /\d*\.\d+([eE]\-?\d+)?/, Num::Float
|
66
|
-
rule /0x[\da-fA-F]+/, Num::Hex
|
67
|
-
rule /\d+L?/, Num::Integer
|
68
|
-
rule /\n/, Text
|
62
|
+
rule %r/#{id}:/, Name::Label
|
63
|
+
rule %r/\$?#{id}/, Name
|
64
|
+
rule %r/[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
|
65
|
+
rule %r/\d*\.\d+([eE]\-?\d+)?/, Num::Float
|
66
|
+
rule %r/0x[\da-fA-F]+/, Num::Hex
|
67
|
+
rule %r/\d+L?/, Num::Integer
|
68
|
+
rule %r/\n/, Text
|
69
69
|
end
|
70
70
|
|
71
71
|
state :class do
|
72
|
-
rule /\s+/m, Text
|
72
|
+
rule %r/\s+/m, Text
|
73
73
|
rule id, Name::Class, :pop!
|
74
74
|
end
|
75
75
|
|
76
76
|
state :dqs do
|
77
|
-
rule /"/, Str, :pop!
|
78
|
-
rule /[^\\\$"]+/, Str
|
77
|
+
rule %r/"/, Str, :pop!
|
78
|
+
rule %r/[^\\\$"]+/, Str
|
79
79
|
mixin :string
|
80
80
|
end
|
81
81
|
|
82
82
|
state :sqs do
|
83
|
-
rule /'/, Str, :pop!
|
84
|
-
rule /[^\\\$']+/, Str
|
83
|
+
rule %r/'/, Str, :pop!
|
84
|
+
rule %r/[^\\\$']+/, Str
|
85
85
|
mixin :string
|
86
86
|
end
|
87
87
|
|
88
88
|
state :import do
|
89
|
-
rule /;/, Operator, :pop!
|
90
|
-
rule /(?:show|hide)\b/, Keyword::Declaration
|
89
|
+
rule %r/;/, Operator, :pop!
|
90
|
+
rule %r/(?:show|hide)\b/, Keyword::Declaration
|
91
91
|
mixin :root
|
92
92
|
end
|
93
93
|
|
94
94
|
state :string do
|
95
95
|
mixin :interpolation
|
96
|
-
rule /\\[nrt\"\'\\]/, Str::Escape
|
96
|
+
rule %r/\\[nrt\"\'\\]/, Str::Escape
|
97
97
|
end
|
98
98
|
|
99
99
|
state :interpolation do
|
100
|
-
rule /\$#{id}/, Str::Interpol
|
101
|
-
rule /\$\{[^\}]+\}/, Str::Interpol
|
100
|
+
rule %r/\$#{id}/, Str::Interpol
|
101
|
+
rule %r/\$\{[^\}]+\}/, Str::Interpol
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|