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/rust.rb
CHANGED
@@ -62,51 +62,51 @@ module Rouge
|
|
62
62
|
|
63
63
|
state :start_line do
|
64
64
|
mixin :whitespace
|
65
|
-
rule /\s+/, Text
|
66
|
-
rule /#\[/ do
|
65
|
+
rule %r/\s+/, Text
|
66
|
+
rule %r/#\[/ do
|
67
67
|
token Name::Decorator; push :attribute
|
68
68
|
end
|
69
69
|
rule(//) { pop! }
|
70
|
-
rule /#\s[^\n]*/, Comment::Preproc
|
70
|
+
rule %r/#\s[^\n]*/, Comment::Preproc
|
71
71
|
end
|
72
72
|
|
73
73
|
state :attribute do
|
74
74
|
mixin :whitespace
|
75
75
|
mixin :has_literals
|
76
|
-
rule /[(,)=]/, Name::Decorator
|
77
|
-
rule /\]/, Name::Decorator, :pop!
|
76
|
+
rule %r/[(,)=]/, Name::Decorator
|
77
|
+
rule %r/\]/, Name::Decorator, :pop!
|
78
78
|
rule id, Name::Decorator
|
79
79
|
end
|
80
80
|
|
81
81
|
state :whitespace do
|
82
|
-
rule /\s+/, Text
|
82
|
+
rule %r/\s+/, Text
|
83
83
|
rule %r(//[^\n]*), Comment
|
84
84
|
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
85
85
|
end
|
86
86
|
|
87
87
|
state :root do
|
88
|
-
rule /\n/, Text, :start_line
|
88
|
+
rule %r/\n/, Text, :start_line
|
89
89
|
mixin :whitespace
|
90
|
-
rule /\b(?:#{Rust.keywords.join('|')})\b/, Keyword
|
90
|
+
rule %r/\b(?:#{Rust.keywords.join('|')})\b/, Keyword
|
91
91
|
mixin :has_literals
|
92
92
|
|
93
93
|
rule %r([=-]>), Keyword
|
94
94
|
rule %r(<->), Keyword
|
95
|
-
rule /[()\[\]{}|,:;]/, Punctuation
|
96
|
-
rule /[
|
95
|
+
rule %r/[()\[\]{}|,:;]/, Punctuation
|
96
|
+
rule %r/[*!@~&+%^<>=\?-]|\.{2,3}/, Operator
|
97
97
|
|
98
|
-
rule /([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
|
99
|
-
rule /[.]\s*#{id}/, Name::Property
|
100
|
-
rule /(#{id})(::)/m do
|
98
|
+
rule %r/([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
|
99
|
+
rule %r/[.]\s*#{id}/, Name::Property
|
100
|
+
rule %r/(#{id})(::)/m do
|
101
101
|
groups Name::Namespace, Punctuation
|
102
102
|
end
|
103
103
|
|
104
104
|
# macros
|
105
|
-
rule /\bmacro_rules!/, Name::Decorator, :macro_rules
|
106
|
-
rule /#{id}!/, Name::Decorator, :macro
|
105
|
+
rule %r/\bmacro_rules!/, Name::Decorator, :macro_rules
|
106
|
+
rule %r/#{id}!/, Name::Decorator, :macro
|
107
107
|
|
108
|
-
rule /'#{id}/, Name::Variable
|
109
|
-
rule /#{id}/ do |m|
|
108
|
+
rule %r/'#{id}/, Name::Variable
|
109
|
+
rule %r/#{id}/ do |m|
|
110
110
|
name = m[0]
|
111
111
|
if self.class.builtins.include? name
|
112
112
|
token Name::Builtin
|
@@ -119,13 +119,13 @@ module Rouge
|
|
119
119
|
state :macro do
|
120
120
|
mixin :has_literals
|
121
121
|
|
122
|
-
rule /[\[{(]/ do |m|
|
122
|
+
rule %r/[\[{(]/ do |m|
|
123
123
|
@macro_delims[delim_map[m[0]]] += 1
|
124
124
|
puts " macro_delims: #{@macro_delims.inspect}" if @debug
|
125
125
|
token Punctuation
|
126
126
|
end
|
127
127
|
|
128
|
-
rule /[\]})]/ do |m|
|
128
|
+
rule %r/[\]})]/ do |m|
|
129
129
|
@macro_delims[m[0]] -= 1
|
130
130
|
puts " macro_delims: #{@macro_delims.inspect}" if @debug
|
131
131
|
pop! if macro_closed?
|
@@ -133,29 +133,29 @@ module Rouge
|
|
133
133
|
end
|
134
134
|
|
135
135
|
# same as the rule in root, but don't push another macro state
|
136
|
-
rule /#{id}!/, Name::Decorator
|
136
|
+
rule %r/#{id}!/, Name::Decorator
|
137
137
|
mixin :root
|
138
138
|
|
139
139
|
# No syntax errors in macros
|
140
|
-
rule /./, Text
|
140
|
+
rule %r/./, Text
|
141
141
|
end
|
142
142
|
|
143
143
|
state :macro_rules do
|
144
|
-
rule /[$]#{id}(:#{id})?/, Name::Variable
|
145
|
-
rule /[$]/, Name::Variable
|
144
|
+
rule %r/[$]#{id}(:#{id})?/, Name::Variable
|
145
|
+
rule %r/[$]/, Name::Variable
|
146
146
|
|
147
147
|
mixin :macro
|
148
148
|
end
|
149
149
|
|
150
150
|
state :has_literals do
|
151
151
|
# constants
|
152
|
-
rule /\b(?:true|false|nil)\b/, Keyword::Constant
|
152
|
+
rule %r/\b(?:true|false|nil)\b/, Keyword::Constant
|
153
153
|
# characters
|
154
154
|
rule %r(
|
155
155
|
' (?: #{escapes} | [^\\] ) '
|
156
156
|
)x, Str::Char
|
157
157
|
|
158
|
-
rule /"/, Str, :string
|
158
|
+
rule %r/"/, Str, :string
|
159
159
|
|
160
160
|
# numbers
|
161
161
|
dot = /[.][0-9_]+/
|
@@ -172,17 +172,17 @@ module Rouge
|
|
172
172
|
|
173
173
|
rule %r(
|
174
174
|
( 0b[10_]+
|
175
|
-
| 0x[0-9a-fA-
|
176
|
-
| [0-
|
175
|
+
| 0x[0-9a-fA-F_]+
|
176
|
+
| [0-9_]+
|
177
177
|
) (u#{size}?|i#{size})?
|
178
178
|
)x, Num::Integer
|
179
179
|
|
180
180
|
end
|
181
181
|
|
182
182
|
state :string do
|
183
|
-
rule /"/, Str, :pop!
|
183
|
+
rule %r/"/, Str, :pop!
|
184
184
|
rule escapes, Str::Escape
|
185
|
-
rule /%%/, Str::Interpol
|
185
|
+
rule %r/%%/, Str::Interpol
|
186
186
|
rule %r(
|
187
187
|
%
|
188
188
|
( [0-9]+ [$] )? # Parameter
|
@@ -191,7 +191,7 @@ module Rouge
|
|
191
191
|
( [.] [0-9]+ )? # Precision
|
192
192
|
[bcdfiostuxX?] # Type
|
193
193
|
)x, Str::Interpol
|
194
|
-
rule /[^%"\\]+/m, Str
|
194
|
+
rule %r/[^%"\\]+/m, Str
|
195
195
|
end
|
196
196
|
end
|
197
197
|
end
|
data/lib/rouge/lexers/sass.rb
CHANGED
@@ -18,7 +18,7 @@ module Rouge
|
|
18
18
|
id = /[\w-]+/
|
19
19
|
|
20
20
|
state :root do
|
21
|
-
rule /[ \t]*\n/, Text
|
21
|
+
rule %r/[ \t]*\n/, Text
|
22
22
|
rule(/[ \t]*/) { |m| token Text; indentation(m[0]) }
|
23
23
|
end
|
24
24
|
|
@@ -34,14 +34,14 @@ module Rouge
|
|
34
34
|
pop!; starts_block :multi_comment
|
35
35
|
end
|
36
36
|
|
37
|
-
rule /@import\b/, Keyword, :import
|
37
|
+
rule %r/@import\b/, Keyword, :import
|
38
38
|
|
39
39
|
mixin :content_common
|
40
40
|
|
41
41
|
rule %r(=#{id}), Name::Function, :value
|
42
42
|
rule %r([+]#{id}), Name::Decorator, :value
|
43
43
|
|
44
|
-
rule /:/, Name::Attribute, :old_style_attr
|
44
|
+
rule %r/:/, Name::Attribute, :old_style_attr
|
45
45
|
|
46
46
|
rule(/(?=[^\[\n]+?:([^a-z]|$))/) { push :attribute }
|
47
47
|
|
@@ -49,17 +49,17 @@ module Rouge
|
|
49
49
|
end
|
50
50
|
|
51
51
|
state :single_comment do
|
52
|
-
rule /.*?$/, Comment::Single, :pop!
|
52
|
+
rule %r/.*?$/, Comment::Single, :pop!
|
53
53
|
end
|
54
54
|
|
55
55
|
state :multi_comment do
|
56
|
-
rule /.*?\n/, Comment::Multiline, :pop!
|
56
|
+
rule %r/.*?\n/, Comment::Multiline, :pop!
|
57
57
|
end
|
58
58
|
|
59
59
|
state :import do
|
60
|
-
rule /[ \t]+/, Text
|
61
|
-
rule /\S+/, Str
|
62
|
-
rule /\n/, Text, :pop!
|
60
|
+
rule %r/[ \t]+/, Text
|
61
|
+
rule %r/\S+/, Str
|
62
|
+
rule %r/\n/, Text, :pop!
|
63
63
|
end
|
64
64
|
|
65
65
|
state :old_style_attr do
|
@@ -8,30 +8,30 @@ module Rouge
|
|
8
8
|
id = /[\w-]+/
|
9
9
|
|
10
10
|
state :content_common do
|
11
|
-
rule /@for\b/, Keyword, :for
|
12
|
-
rule /@(debug|warn|if|each|while|else|return|media)/, Keyword, :value
|
11
|
+
rule %r/@for\b/, Keyword, :for
|
12
|
+
rule %r/@(debug|warn|if|each|while|else|return|media)/, Keyword, :value
|
13
13
|
|
14
|
-
rule /(@mixin)(\s+)(#{id})/ do
|
14
|
+
rule %r/(@mixin)(\s+)(#{id})/ do
|
15
15
|
groups Keyword, Text, Name::Function
|
16
16
|
push :value
|
17
17
|
end
|
18
18
|
|
19
|
-
rule /(@function)(\s+)(#{id})/ do
|
19
|
+
rule %r/(@function)(\s+)(#{id})/ do
|
20
20
|
groups Keyword, Text, Name::Function
|
21
21
|
push :value
|
22
22
|
end
|
23
23
|
|
24
|
-
rule /@extend\b/, Keyword, :selector
|
24
|
+
rule %r/@extend\b/, Keyword, :selector
|
25
25
|
|
26
|
-
rule /(@include)(\s+)(#{id})/ do
|
26
|
+
rule %r/(@include)(\s+)(#{id})/ do
|
27
27
|
groups Keyword, Text, Name::Decorator
|
28
28
|
push :value
|
29
29
|
end
|
30
30
|
|
31
|
-
rule /@#{id}/, Keyword, :selector
|
31
|
+
rule %r/@#{id}/, Keyword, :selector
|
32
32
|
|
33
33
|
# $variable: assignment
|
34
|
-
rule /([$]#{id})([ \t]*)(:)/ do
|
34
|
+
rule %r/([$]#{id})([ \t]*)(:)/ do
|
35
35
|
groups Name::Variable, Text, Punctuation
|
36
36
|
push :value
|
37
37
|
end
|
@@ -39,26 +39,26 @@ module Rouge
|
|
39
39
|
|
40
40
|
state :value do
|
41
41
|
mixin :end_section
|
42
|
-
rule /[ \t]+/, Text
|
43
|
-
rule /[$]#{id}/, Name::Variable
|
44
|
-
rule /url[(]/, Str::Other, :string_url
|
45
|
-
rule /#{id}(?=\s*[(])/, Name::Function
|
46
|
-
rule /%#{id}/, Name::Decorator
|
42
|
+
rule %r/[ \t]+/, Text
|
43
|
+
rule %r/[$]#{id}/, Name::Variable
|
44
|
+
rule %r/url[(]/, Str::Other, :string_url
|
45
|
+
rule %r/#{id}(?=\s*[(])/, Name::Function
|
46
|
+
rule %r/%#{id}/, Name::Decorator
|
47
47
|
|
48
48
|
# named literals
|
49
|
-
rule /(true|false)\b/, Name::Builtin::Pseudo
|
50
|
-
rule /(and|or|not)\b/, Operator::Word
|
49
|
+
rule %r/(true|false)\b/, Name::Builtin::Pseudo
|
50
|
+
rule %r/(and|or|not)\b/, Operator::Word
|
51
51
|
|
52
52
|
# colors and numbers
|
53
|
-
rule /#[a-z0-9]{1,6}/i, Num::Hex
|
54
|
-
rule /-?\d+(%|[a-z]+)?/, Num
|
55
|
-
rule /-?\d*\.\d+(%|[a-z]+)?/, Num::Integer
|
53
|
+
rule %r/#[a-z0-9]{1,6}/i, Num::Hex
|
54
|
+
rule %r/-?\d+(%|[a-z]+)?/, Num
|
55
|
+
rule %r/-?\d*\.\d+(%|[a-z]+)?/, Num::Integer
|
56
56
|
|
57
57
|
mixin :has_strings
|
58
58
|
mixin :has_interp
|
59
59
|
|
60
|
-
rule /[~^*!&%<>\|+=@:,.\/?-]+/, Operator
|
61
|
-
rule /[\[\]()]+/, Punctuation
|
60
|
+
rule %r/[~^*!&%<>\|+=@:,.\/?-]+/, Operator
|
61
|
+
rule %r/[\[\]()]+/, Punctuation
|
62
62
|
rule %r(/[*]), Comment::Multiline, :inline_comment
|
63
63
|
rule %r(//[^\n]*), Comment::Single
|
64
64
|
|
@@ -75,16 +75,16 @@ module Rouge
|
|
75
75
|
end
|
76
76
|
|
77
77
|
state :has_interp do
|
78
|
-
rule /[#][{]/, Str::Interpol, :interpolation
|
78
|
+
rule %r/[#][{]/, Str::Interpol, :interpolation
|
79
79
|
end
|
80
80
|
|
81
81
|
state :has_strings do
|
82
|
-
rule /"/, Str::Double, :dq
|
83
|
-
rule /'/, Str::Single, :sq
|
82
|
+
rule %r/"/, Str::Double, :dq
|
83
|
+
rule %r/'/, Str::Single, :sq
|
84
84
|
end
|
85
85
|
|
86
86
|
state :interpolation do
|
87
|
-
rule /}/, Str::Interpol, :pop!
|
87
|
+
rule %r/}/, Str::Interpol, :pop!
|
88
88
|
mixin :value
|
89
89
|
end
|
90
90
|
|
@@ -93,31 +93,31 @@ module Rouge
|
|
93
93
|
|
94
94
|
mixin :has_strings
|
95
95
|
mixin :has_interp
|
96
|
-
rule /[ \t]+/, Text
|
97
|
-
rule /:/, Name::Decorator, :pseudo_class
|
98
|
-
rule /[.]/, Name::Class, :class
|
99
|
-
rule /#/, Name::Namespace, :id
|
100
|
-
rule /%/, Name::Variable, :placeholder
|
96
|
+
rule %r/[ \t]+/, Text
|
97
|
+
rule %r/:/, Name::Decorator, :pseudo_class
|
98
|
+
rule %r/[.]/, Name::Class, :class
|
99
|
+
rule %r/#/, Name::Namespace, :id
|
100
|
+
rule %r/%/, Name::Variable, :placeholder
|
101
101
|
rule id, Name::Tag
|
102
|
-
rule /&/, Keyword
|
103
|
-
rule /[~^*!&\[\]()<>\|+=@:;,.\/?-]/, Operator
|
102
|
+
rule %r/&/, Keyword
|
103
|
+
rule %r/[~^*!&\[\]()<>\|+=@:;,.\/?-]/, Operator
|
104
104
|
end
|
105
105
|
|
106
106
|
state :dq do
|
107
|
-
rule /"/, Str::Double, :pop!
|
107
|
+
rule %r/"/, Str::Double, :pop!
|
108
108
|
mixin :has_interp
|
109
|
-
rule /(\\.|#(?![{])|[^\n"#])+/, Str::Double
|
109
|
+
rule %r/(\\.|#(?![{])|[^\n"#])+/, Str::Double
|
110
110
|
end
|
111
111
|
|
112
112
|
state :sq do
|
113
|
-
rule /'/, Str::Single, :pop!
|
113
|
+
rule %r/'/, Str::Single, :pop!
|
114
114
|
mixin :has_interp
|
115
|
-
rule /(\\.|#(?![{])|[^\n'#])+/, Str::Single
|
115
|
+
rule %r/(\\.|#(?![{])|[^\n'#])+/, Str::Single
|
116
116
|
end
|
117
117
|
|
118
118
|
state :string_url do
|
119
|
-
rule /[)]/, Str::Other, :pop!
|
120
|
-
rule /(\\.|#(?![{])|[^\n)#])+/, Str::Other
|
119
|
+
rule %r/[)]/, Str::Other, :pop!
|
120
|
+
rule %r/(\\.|#(?![{])|[^\n)#])+/, Str::Other
|
121
121
|
mixin :has_interp
|
122
122
|
end
|
123
123
|
|
@@ -147,7 +147,7 @@ module Rouge
|
|
147
147
|
end
|
148
148
|
|
149
149
|
state :for do
|
150
|
-
rule /(from|to|through)/, Operator::Word
|
150
|
+
rule %r/(from|to|through)/, Operator::Word
|
151
151
|
mixin :value
|
152
152
|
end
|
153
153
|
|
@@ -165,14 +165,14 @@ module Rouge
|
|
165
165
|
state :attribute do
|
166
166
|
mixin :attr_common
|
167
167
|
|
168
|
-
rule /([ \t]*)(:)/ do
|
168
|
+
rule %r/([ \t]*)(:)/ do
|
169
169
|
groups Text, Punctuation
|
170
170
|
push :value
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
174
|
state :inline_comment do
|
175
|
-
rule /(\\#|#(?=[^\n{])|\*(?=[^\n\/])|[^\n#*])+/, Comment::Multiline
|
175
|
+
rule %r/(\\#|#(?=[^\n{])|\*(?=[^\n\/])|[^\n#*])+/, Comment::Multiline
|
176
176
|
mixin :has_interp
|
177
177
|
rule %r([*]/), Comment::Multiline, :pop!
|
178
178
|
end
|
data/lib/rouge/lexers/scala.rb
CHANGED
@@ -36,41 +36,41 @@ module Rouge
|
|
36
36
|
)
|
37
37
|
|
38
38
|
state :root do
|
39
|
-
rule /(class|trait|object)(\s+)/ do
|
39
|
+
rule %r/(class|trait|object)(\s+)/ do
|
40
40
|
groups Keyword, Text
|
41
41
|
push :class
|
42
42
|
end
|
43
|
-
rule /'#{idrest}[^']/, Str::Symbol
|
44
|
-
rule /[^\S\n]+/, Text
|
43
|
+
rule %r/'#{idrest}[^']/, Str::Symbol
|
44
|
+
rule %r/[^\S\n]+/, Text
|
45
45
|
|
46
46
|
rule %r(//.*?\n), Comment::Single
|
47
47
|
rule %r(/\*), Comment::Multiline, :comment
|
48
48
|
|
49
|
-
rule /@#{idrest}/, Name::Decorator
|
49
|
+
rule %r/@#{idrest}/, Name::Decorator
|
50
50
|
|
51
|
-
rule /(def)(\s+)(#{idrest}|#{op}+|`[^`]+`)(\s*)/ do
|
51
|
+
rule %r/(def)(\s+)(#{idrest}|#{op}+|`[^`]+`)(\s*)/ do
|
52
52
|
groups Keyword, Text, Name::Function, Text
|
53
53
|
end
|
54
54
|
|
55
|
-
rule /(val)(\s+)(#{idrest}|#{op}+|`[^`]+`)(\s*)/ do
|
55
|
+
rule %r/(val)(\s+)(#{idrest}|#{op}+|`[^`]+`)(\s*)/ do
|
56
56
|
groups Keyword, Text, Name::Variable, Text
|
57
57
|
end
|
58
58
|
|
59
|
-
rule /(this)(\n*)(\.)(#{idrest})/ do
|
59
|
+
rule %r/(this)(\n*)(\.)(#{idrest})/ do
|
60
60
|
groups Keyword, Text, Operator, Name::Property
|
61
61
|
end
|
62
62
|
|
63
|
-
rule /(#{idrest}|_)(\n*)(\.)(#{idrest})/ do
|
63
|
+
rule %r/(#{idrest}|_)(\n*)(\.)(#{idrest})/ do
|
64
64
|
groups Name::Variable, Text, Operator, Name::Property
|
65
65
|
end
|
66
66
|
|
67
|
-
rule /#{upper}#{idrest}\b/, Name::Class
|
67
|
+
rule %r/#{upper}#{idrest}\b/, Name::Class
|
68
68
|
|
69
|
-
rule /(#{idrest})(#{whitespace}*)(\()/ do
|
69
|
+
rule %r/(#{idrest})(#{whitespace}*)(\()/ do
|
70
70
|
groups Name::Function, Text, Operator
|
71
71
|
end
|
72
72
|
|
73
|
-
rule /(\.)(#{idrest})/ do
|
73
|
+
rule %r/(\.)(#{idrest})/ do
|
74
74
|
groups Operator, Name::Property
|
75
75
|
end
|
76
76
|
|
@@ -78,80 +78,80 @@ module Rouge
|
|
78
78
|
(#{keywords.join("|")})\b|
|
79
79
|
(<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\b|(?=\s)|$)
|
80
80
|
)x, Keyword
|
81
|
-
rule /:(?!#{op})/, Keyword, :type
|
82
|
-
rule /(true|false|null)\b/, Keyword::Constant
|
83
|
-
rule /(import|package)(\s+)/ do
|
81
|
+
rule %r/:(?!#{op})/, Keyword, :type
|
82
|
+
rule %r/(true|false|null)\b/, Keyword::Constant
|
83
|
+
rule %r/(import|package)(\s+)/ do
|
84
84
|
groups Keyword, Text
|
85
85
|
push :import
|
86
86
|
end
|
87
87
|
|
88
|
-
rule /(type)(\s+)/ do
|
88
|
+
rule %r/(type)(\s+)/ do
|
89
89
|
groups Keyword, Text
|
90
90
|
push :type
|
91
91
|
end
|
92
92
|
|
93
|
-
rule /""".*?"""(?!")/m, Str
|
94
|
-
rule /"(\\\\|\\"|[^"])*"/, Str
|
95
|
-
rule /'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'/, Str::Char
|
93
|
+
rule %r/""".*?"""(?!")/m, Str
|
94
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Str
|
95
|
+
rule %r/'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'/, Str::Char
|
96
96
|
|
97
97
|
rule idrest, Name
|
98
|
-
rule /`[^`]+`/, Name
|
98
|
+
rule %r/`[^`]+`/, Name
|
99
99
|
|
100
|
-
rule /\[/, Operator, :typeparam
|
101
|
-
rule /[\(\)\{\};,.#]/, Operator
|
102
|
-
rule /#{op}+/, Operator
|
100
|
+
rule %r/\[/, Operator, :typeparam
|
101
|
+
rule %r/[\(\)\{\};,.#]/, Operator
|
102
|
+
rule %r/#{op}+/, Operator
|
103
103
|
|
104
|
-
rule /([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?/, Num::Float
|
105
|
-
rule /([0-9][0-9]*[fFdD])/, Num::Float
|
106
|
-
rule /0x[0-9a-fA-F]+/, Num::Hex
|
107
|
-
rule /[0-9]+L?/, Num::Integer
|
108
|
-
rule /\n/, Text
|
104
|
+
rule %r/([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?/, Num::Float
|
105
|
+
rule %r/([0-9][0-9]*[fFdD])/, Num::Float
|
106
|
+
rule %r/0x[0-9a-fA-F]+/, Num::Hex
|
107
|
+
rule %r/[0-9]+L?/, Num::Integer
|
108
|
+
rule %r/\n/, Text
|
109
109
|
end
|
110
110
|
|
111
111
|
state :class do
|
112
|
-
rule /(#{idrest}|#{op}+|`[^`]+`)(\s*)(\[)/ do
|
112
|
+
rule %r/(#{idrest}|#{op}+|`[^`]+`)(\s*)(\[)/ do
|
113
113
|
groups Name::Class, Text, Operator
|
114
114
|
push :typeparam
|
115
115
|
end
|
116
116
|
|
117
|
-
rule /\s+/, Text
|
118
|
-
rule /{/, Operator, :pop!
|
119
|
-
rule /\(/, Operator, :pop!
|
117
|
+
rule %r/\s+/, Text
|
118
|
+
rule %r/{/, Operator, :pop!
|
119
|
+
rule %r/\(/, Operator, :pop!
|
120
120
|
rule %r(//.*?\n), Comment::Single, :pop!
|
121
121
|
rule %r(#{idrest}|#{op}+|`[^`]+`), Name::Class, :pop!
|
122
122
|
end
|
123
123
|
|
124
124
|
state :type do
|
125
|
-
rule /\s+/, Text
|
126
|
-
rule /<[%:]|>:|[#_\u21D2]|forSome|type/, Keyword
|
127
|
-
rule /([,\);}]|=>|=)(\s*)/ do
|
125
|
+
rule %r/\s+/, Text
|
126
|
+
rule %r/<[%:]|>:|[#_\u21D2]|forSome|type/, Keyword
|
127
|
+
rule %r/([,\);}]|=>|=)(\s*)/ do
|
128
128
|
groups Operator, Text
|
129
129
|
pop!
|
130
130
|
end
|
131
|
-
rule /[\(\{]/, Operator, :type
|
131
|
+
rule %r/[\(\{]/, Operator, :type
|
132
132
|
|
133
133
|
typechunk = /(?:#{idrest}|#{op}+\`[^`]+`)/
|
134
|
-
rule /(#{typechunk}(?:\.#{typechunk})*)(\s*)(\[)/ do
|
134
|
+
rule %r/(#{typechunk}(?:\.#{typechunk})*)(\s*)(\[)/ do
|
135
135
|
groups Keyword::Type, Text, Operator
|
136
136
|
pop!
|
137
137
|
push :typeparam
|
138
138
|
end
|
139
139
|
|
140
|
-
rule /(#{typechunk}(?:\.#{typechunk})*)(\s*)$/ do
|
140
|
+
rule %r/(#{typechunk}(?:\.#{typechunk})*)(\s*)$/ do
|
141
141
|
groups Keyword::Type, Text
|
142
142
|
pop!
|
143
143
|
end
|
144
144
|
|
145
145
|
rule %r(//.*?\n), Comment::Single, :pop!
|
146
|
-
rule /\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type
|
146
|
+
rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type
|
147
147
|
end
|
148
148
|
|
149
149
|
state :typeparam do
|
150
|
-
rule /[\s,]+/, Text
|
151
|
-
rule /<[%:]|=>|>:|[#_\u21D2]|forSome|type/, Keyword
|
152
|
-
rule /([\]\)\}])/, Operator, :pop!
|
153
|
-
rule /[\(\[\{]/, Operator, :typeparam
|
154
|
-
rule /\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type
|
150
|
+
rule %r/[\s,]+/, Text
|
151
|
+
rule %r/<[%:]|=>|>:|[#_\u21D2]|forSome|type/, Keyword
|
152
|
+
rule %r/([\]\)\}])/, Operator, :pop!
|
153
|
+
rule %r/[\(\[\{]/, Operator, :typeparam
|
154
|
+
rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type
|
155
155
|
end
|
156
156
|
|
157
157
|
state :comment do
|