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/pascal.rb
CHANGED
@@ -40,7 +40,7 @@ module Rouge
|
|
40
40
|
|
41
41
|
state :whitespace do
|
42
42
|
# Spaces
|
43
|
-
rule /\s+/m, Text
|
43
|
+
rule %r/\s+/m, Text
|
44
44
|
# // Comments
|
45
45
|
rule %r((//).*$\n?), Comment::Single
|
46
46
|
# -- Comments
|
@@ -57,9 +57,9 @@ module Rouge
|
|
57
57
|
rule %r{((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?}, Num
|
58
58
|
rule %r{[~!@#\$%\^&\*\(\)\+`\-={}\[\]:;<>\?,\.\/\|\\]}, Punctuation
|
59
59
|
rule %r{'([^']|'')*'}, Str
|
60
|
-
rule /(true|false|nil)\b/i, Name::Builtin
|
61
|
-
rule /\b(#{keywords.join('|')})\b/i, Keyword
|
62
|
-
rule /\b(#{keywords_type.join('|')})\b/i, Keyword::Type
|
60
|
+
rule %r/(true|false|nil)\b/i, Name::Builtin
|
61
|
+
rule %r/\b(#{keywords.join('|')})\b/i, Keyword
|
62
|
+
rule %r/\b(#{keywords_type.join('|')})\b/i, Keyword::Type
|
63
63
|
rule id, Name
|
64
64
|
end
|
65
65
|
end
|
data/lib/rouge/lexers/perl.rb
CHANGED
@@ -65,17 +65,17 @@ module Rouge
|
|
65
65
|
end
|
66
66
|
|
67
67
|
state :root do
|
68
|
-
rule /#.*?$/, Comment::Single
|
69
|
-
rule /^=[a-zA-Z0-9]+\s+.*?\n=cut/m, Comment::Multiline
|
70
|
-
rule /(?:#{keywords.join('|')})\b/, Keyword
|
68
|
+
rule %r/#.*?$/, Comment::Single
|
69
|
+
rule %r/^=[a-zA-Z0-9]+\s+.*?\n=cut/m, Comment::Multiline
|
70
|
+
rule %r/(?:#{keywords.join('|')})\b/, Keyword
|
71
71
|
|
72
|
-
rule /(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)/ do
|
72
|
+
rule %r/(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)/ do
|
73
73
|
groups Keyword, Text, Name, Text, Punctuation, Text
|
74
74
|
|
75
75
|
push :format
|
76
76
|
end
|
77
77
|
|
78
|
-
rule /(?:eq|lt|gt|le|ge|ne|not|and|or|cmp)\b/, Operator::Word
|
78
|
+
rule %r/(?:eq|lt|gt|le|ge|ne|not|and|or|cmp)\b/, Operator::Word
|
79
79
|
|
80
80
|
# common delimiters
|
81
81
|
rule %r(s/(\\\\|\\/|[^/])*/(\\\\|\\/|[^/])*/[msixpodualngc]*), re_tok
|
@@ -100,103 +100,103 @@ module Rouge
|
|
100
100
|
rule %r(((?<==~)|(?<=\())\s*/(\\\\|\\/|[^/])*/[msixpodualngc]*),
|
101
101
|
re_tok, :balanced_regex
|
102
102
|
|
103
|
-
rule /\s+/, Text
|
104
|
-
rule /(?:#{builtins.join('|')})\b/, Name::Builtin
|
105
|
-
rule /((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b/,
|
103
|
+
rule %r/\s+/, Text
|
104
|
+
rule %r/(?:#{builtins.join('|')})\b/, Name::Builtin
|
105
|
+
rule %r/((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b/,
|
106
106
|
Name::Builtin::Pseudo
|
107
107
|
|
108
|
-
rule /<<([\'"]?)([a-zA-Z_][a-zA-Z0-9_]*)\1;?\n.*?\n\2\n/m, Str
|
108
|
+
rule %r/<<([\'"]?)([a-zA-Z_][a-zA-Z0-9_]*)\1;?\n.*?\n\2\n/m, Str
|
109
109
|
|
110
|
-
rule /__END__\b/, Comment::Preproc, :end_part
|
111
|
-
rule /\$\^[ADEFHILMOPSTWX]/, Name::Variable::Global
|
112
|
-
rule /\$[\\"'\[\]&`+*.,;=%~?@$!<>(^\|\/-](?!\w)/, Name::Variable::Global
|
113
|
-
rule /[-+\/*%=<>&^\|!\\~]=?/, Operator
|
114
|
-
rule /[$@%#]+/, Name::Variable, :varname
|
110
|
+
rule %r/__END__\b/, Comment::Preproc, :end_part
|
111
|
+
rule %r/\$\^[ADEFHILMOPSTWX]/, Name::Variable::Global
|
112
|
+
rule %r/\$[\\"'\[\]&`+*.,;=%~?@$!<>(^\|\/-](?!\w)/, Name::Variable::Global
|
113
|
+
rule %r/[-+\/*%=<>&^\|!\\~]=?/, Operator
|
114
|
+
rule %r/[$@%#]+/, Name::Variable, :varname
|
115
115
|
|
116
|
-
rule /0_?[0-7]+(_[0-7]+)*/, Num::Oct
|
117
|
-
rule /0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*/, Num::Hex
|
118
|
-
rule /0b[01]+(_[01]+)*/, Num::Bin
|
119
|
-
rule /(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?/i,
|
116
|
+
rule %r/0_?[0-7]+(_[0-7]+)*/, Num::Oct
|
117
|
+
rule %r/0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*/, Num::Hex
|
118
|
+
rule %r/0b[01]+(_[01]+)*/, Num::Bin
|
119
|
+
rule %r/(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?/i,
|
120
120
|
Num::Float
|
121
|
-
rule /\d+(_\d*)*e[+-]?\d+(_\d*)*/i, Num::Float
|
122
|
-
rule /\d+(_\d+)*/, Num::Integer
|
123
|
-
|
124
|
-
rule /'/, Punctuation, :sq
|
125
|
-
rule /"/, Punctuation, :dq
|
126
|
-
rule /`/, Punctuation, :bq
|
127
|
-
rule /<([^\s>]+)>/, re_tok
|
128
|
-
rule /(q|qq|qw|qr|qx)\{/, Str::Other, :cb_string
|
129
|
-
rule /(q|qq|qw|qr|qx)\(/, Str::Other, :rb_string
|
130
|
-
rule /(q|qq|qw|qr|qx)\[/, Str::Other, :sb_string
|
131
|
-
rule /(q|qq|qw|qr|qx)</, Str::Other, :lt_string
|
132
|
-
rule /(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2/, Str::Other
|
133
|
-
|
134
|
-
rule /package\s+/, Keyword, :modulename
|
135
|
-
rule /sub\s+/, Keyword, :funcname
|
136
|
-
rule /\[\]|\*\*|::|<<|>>|>=|<=|<=>|={3}|!=|=~|!~|&&?|\|\||\.{1,3}/,
|
121
|
+
rule %r/\d+(_\d*)*e[+-]?\d+(_\d*)*/i, Num::Float
|
122
|
+
rule %r/\d+(_\d+)*/, Num::Integer
|
123
|
+
|
124
|
+
rule %r/'/, Punctuation, :sq
|
125
|
+
rule %r/"/, Punctuation, :dq
|
126
|
+
rule %r/`/, Punctuation, :bq
|
127
|
+
rule %r/<([^\s>]+)>/, re_tok
|
128
|
+
rule %r/(q|qq|qw|qr|qx)\{/, Str::Other, :cb_string
|
129
|
+
rule %r/(q|qq|qw|qr|qx)\(/, Str::Other, :rb_string
|
130
|
+
rule %r/(q|qq|qw|qr|qx)\[/, Str::Other, :sb_string
|
131
|
+
rule %r/(q|qq|qw|qr|qx)</, Str::Other, :lt_string
|
132
|
+
rule %r/(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2/, Str::Other
|
133
|
+
|
134
|
+
rule %r/package\s+/, Keyword, :modulename
|
135
|
+
rule %r/sub\s+/, Keyword, :funcname
|
136
|
+
rule %r/\[\]|\*\*|::|<<|>>|>=|<=|<=>|={3}|!=|=~|!~|&&?|\|\||\.{1,3}/,
|
137
137
|
Operator
|
138
|
-
rule /[()\[\]:;,<>\/?{}]/, Punctuation
|
138
|
+
rule %r/[()\[\]:;,<>\/?{}]/, Punctuation
|
139
139
|
rule(/(?=\w)/) { push :name }
|
140
140
|
end
|
141
141
|
|
142
142
|
state :format do
|
143
|
-
rule /\.\n/, Str::Interpol, :pop!
|
144
|
-
rule /.*?\n/, Str::Interpol
|
143
|
+
rule %r/\.\n/, Str::Interpol, :pop!
|
144
|
+
rule %r/.*?\n/, Str::Interpol
|
145
145
|
end
|
146
146
|
|
147
147
|
state :name_common do
|
148
|
-
rule /\w+::/, Name::Namespace
|
149
|
-
rule /[\w:]+/, Name::Variable, :pop!
|
148
|
+
rule %r/\w+::/, Name::Namespace
|
149
|
+
rule %r/[\w:]+/, Name::Variable, :pop!
|
150
150
|
end
|
151
151
|
|
152
152
|
state :varname do
|
153
|
-
rule /\s+/, Text
|
154
|
-
rule /\{/, Punctuation, :pop! # hash syntax
|
155
|
-
rule /\)|,/, Punctuation, :pop! # arg specifier
|
153
|
+
rule %r/\s+/, Text
|
154
|
+
rule %r/\{/, Punctuation, :pop! # hash syntax
|
155
|
+
rule %r/\)|,/, Punctuation, :pop! # arg specifier
|
156
156
|
mixin :name_common
|
157
157
|
end
|
158
158
|
|
159
159
|
state :name do
|
160
160
|
mixin :name_common
|
161
|
-
rule /[A-Z_]+(?=[^a-zA-Z0-9_])/, Name::Constant, :pop!
|
161
|
+
rule %r/[A-Z_]+(?=[^a-zA-Z0-9_])/, Name::Constant, :pop!
|
162
162
|
rule(/(?=\W)/) { pop! }
|
163
163
|
end
|
164
164
|
|
165
165
|
state :modulename do
|
166
|
-
rule /[a-z_]\w*/i, Name::Namespace, :pop!
|
166
|
+
rule %r/[a-z_]\w*/i, Name::Namespace, :pop!
|
167
167
|
end
|
168
168
|
|
169
169
|
state :funcname do
|
170
|
-
rule /[a-zA-Z_]\w*[!?]?/, Name::Function
|
171
|
-
rule /\s+/, Text
|
170
|
+
rule %r/[a-zA-Z_]\w*[!?]?/, Name::Function
|
171
|
+
rule %r/\s+/, Text
|
172
172
|
|
173
173
|
# argument declaration
|
174
|
-
rule /(\([$@%]*\))(\s*)/ do
|
174
|
+
rule %r/(\([$@%]*\))(\s*)/ do
|
175
175
|
groups Punctuation, Text
|
176
176
|
end
|
177
177
|
|
178
|
-
rule /.*?{/, Punctuation, :pop!
|
179
|
-
rule /;/, Punctuation, :pop!
|
178
|
+
rule %r/.*?{/, Punctuation, :pop!
|
179
|
+
rule %r/;/, Punctuation, :pop!
|
180
180
|
end
|
181
181
|
|
182
182
|
state :sq do
|
183
|
-
rule /\\[']/, Str::Escape
|
184
|
-
rule /[^\\']+/, Str::Single
|
185
|
-
rule /'/, Punctuation, :pop!
|
183
|
+
rule %r/\\[']/, Str::Escape
|
184
|
+
rule %r/[^\\']+/, Str::Single
|
185
|
+
rule %r/'/, Punctuation, :pop!
|
186
186
|
end
|
187
187
|
|
188
188
|
state :dq do
|
189
189
|
mixin :string_intp
|
190
|
-
rule /\\[\\tnr"]/, Str::Escape
|
191
|
-
rule /[^\\"]+?/, Str::Double
|
192
|
-
rule /"/, Punctuation, :pop!
|
190
|
+
rule %r/\\[\\tnr"]/, Str::Escape
|
191
|
+
rule %r/[^\\"]+?/, Str::Double
|
192
|
+
rule %r/"/, Punctuation, :pop!
|
193
193
|
end
|
194
194
|
|
195
195
|
state :bq do
|
196
196
|
mixin :string_intp
|
197
|
-
rule /\\[\\tnr`]/, Str::Escape
|
198
|
-
rule /[^\\`]+?/, Str::Backtick
|
199
|
-
rule /`/, Punctuation, :pop!
|
197
|
+
rule %r/\\[\\tnr`]/, Str::Escape
|
198
|
+
rule %r/[^\\`]+?/, Str::Backtick
|
199
|
+
rule %r/`/, Punctuation, :pop!
|
200
200
|
end
|
201
201
|
|
202
202
|
[[:cb, '\{', '\}'],
|
@@ -205,28 +205,28 @@ module Rouge
|
|
205
205
|
[:lt, '<', '>']].each do |name, open, close|
|
206
206
|
tok = Str::Other
|
207
207
|
state :"#{name}_string" do
|
208
|
-
rule /\\[#{open}#{close}\\]/, tok
|
209
|
-
rule /\\/, tok
|
208
|
+
rule %r/\\[#{open}#{close}\\]/, tok
|
209
|
+
rule %r/\\/, tok
|
210
210
|
rule(/#{open}/) { token tok; push }
|
211
|
-
rule /#{close}/, tok, :pop!
|
212
|
-
rule /[^#{open}#{close}\\]+/, tok
|
211
|
+
rule %r/#{close}/, tok, :pop!
|
212
|
+
rule %r/[^#{open}#{close}\\]+/, tok
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
216
|
state :in_interp do
|
217
|
-
rule /}/, Str::Interpol, :pop!
|
218
|
-
rule /\s+/, Text
|
219
|
-
rule /[a-z_]\w*/i, Str::Interpol
|
217
|
+
rule %r/}/, Str::Interpol, :pop!
|
218
|
+
rule %r/\s+/, Text
|
219
|
+
rule %r/[a-z_]\w*/i, Str::Interpol
|
220
220
|
end
|
221
221
|
|
222
222
|
state :string_intp do
|
223
|
-
rule /[$@][{]/, Str::Interpol, :in_interp
|
224
|
-
rule /[$@][a-z_]\w*/i, Str::Interpol
|
223
|
+
rule %r/[$@][{]/, Str::Interpol, :in_interp
|
224
|
+
rule %r/[$@][a-z_]\w*/i, Str::Interpol
|
225
225
|
end
|
226
226
|
|
227
227
|
state :end_part do
|
228
228
|
# eat the rest of the stream
|
229
|
-
rule /.+/m, Comment::Preproc, :pop!
|
229
|
+
rule %r/.+/m, Comment::Preproc, :pop!
|
230
230
|
end
|
231
231
|
end
|
232
232
|
end
|
data/lib/rouge/lexers/php.rb
CHANGED
@@ -29,7 +29,7 @@ module Rouge
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.builtins
|
32
|
-
load
|
32
|
+
load File.join(__dir__, 'php/builtins.rb')
|
33
33
|
self.builtins
|
34
34
|
end
|
35
35
|
|
@@ -91,49 +91,49 @@ module Rouge
|
|
91
91
|
end
|
92
92
|
|
93
93
|
state :template do
|
94
|
-
rule /<\?(php|=)?/, Comment::Preproc, :php
|
94
|
+
rule %r/<\?(php|=)?/, Comment::Preproc, :php
|
95
95
|
rule(/.*?(?=<\?)|.*/m) { delegate parent }
|
96
96
|
end
|
97
97
|
|
98
98
|
state :php do
|
99
|
-
rule /\?>/, Comment::Preproc, :pop!
|
99
|
+
rule %r/\?>/, Comment::Preproc, :pop!
|
100
100
|
# heredocs
|
101
|
-
rule /<<<('?)(#{id})\1\n.*?\n\2;?\n/im, Str::Heredoc
|
102
|
-
rule /\s+/, Text
|
103
|
-
rule /#.*?$/, Comment::Single
|
101
|
+
rule %r/<<<('?)(#{id})\1\n.*?\n\2;?\n/im, Str::Heredoc
|
102
|
+
rule %r/\s+/, Text
|
103
|
+
rule %r/#.*?$/, Comment::Single
|
104
104
|
rule %r(//.*?$), Comment::Single
|
105
105
|
# empty comment, otherwise seen as the start of a docstring
|
106
106
|
rule %r(/\*\*/), Comment::Multiline
|
107
107
|
rule %r(/\*\*.*?\*/)m, Str::Doc
|
108
108
|
rule %r(/\*.*?\*/)m, Comment::Multiline
|
109
|
-
rule /(->|::)(\s*)(#{id})/ do
|
109
|
+
rule %r/(->|::)(\s*)(#{id})/ do
|
110
110
|
groups Operator, Text, Name::Attribute
|
111
111
|
end
|
112
112
|
|
113
|
-
rule /[~!%^&*+=\|:.<>\/?@-]+/, Operator
|
114
|
-
rule /[\[\]{}();,]/, Punctuation
|
115
|
-
rule /class\b/, Keyword, :classname
|
113
|
+
rule %r/[~!%^&*+=\|:.<>\/?@-]+/, Operator
|
114
|
+
rule %r/[\[\]{}();,]/, Punctuation
|
115
|
+
rule %r/class\b/, Keyword, :classname
|
116
116
|
# anonymous functions
|
117
|
-
rule /(function)(\s*)(?=\()/ do
|
117
|
+
rule %r/(function)(\s*)(?=\()/ do
|
118
118
|
groups Keyword, Text
|
119
119
|
end
|
120
120
|
|
121
121
|
# named functions
|
122
|
-
rule /(function)(\s+)(&?)(\s*)/ do
|
122
|
+
rule %r/(function)(\s+)(&?)(\s*)/ do
|
123
123
|
groups Keyword, Text, Operator, Text
|
124
124
|
push :funcname
|
125
125
|
end
|
126
126
|
|
127
|
-
rule /(const)(\s+)(#{id})/i do
|
127
|
+
rule %r/(const)(\s+)(#{id})/i do
|
128
128
|
groups Keyword, Text, Name::Constant
|
129
129
|
end
|
130
130
|
|
131
|
-
rule /(true|false|null)\b/, Keyword::Constant
|
132
|
-
rule /\$\{\$+#{id}\}/i, Name::Variable
|
133
|
-
rule /\$+#{id}/i, Name::Variable
|
131
|
+
rule %r/(true|false|null)\b/, Keyword::Constant
|
132
|
+
rule %r/\$\{\$+#{id}\}/i, Name::Variable
|
133
|
+
rule %r/\$+#{id}/i, Name::Variable
|
134
134
|
|
135
135
|
# may be intercepted for builtin highlighting
|
136
|
-
rule /\\?#{nsid}/i do |m|
|
136
|
+
rule %r/\\?#{nsid}/i do |m|
|
137
137
|
name = m[0]
|
138
138
|
|
139
139
|
if self.class.keywords.include? name
|
@@ -145,48 +145,48 @@ module Rouge
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
rule /(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?/i, Num::Float
|
149
|
-
rule /\d+e[+-]?\d+/i, Num::Float
|
150
|
-
rule /0[0-7]+/, Num::Oct
|
151
|
-
rule /0x[a-f0-9]+/i, Num::Hex
|
152
|
-
rule /\d+/, Num::Integer
|
153
|
-
rule /'([^'\\]*(?:\\.[^'\\]*)*)'/, Str::Single
|
154
|
-
rule /`([^`\\]*(?:\\.[^`\\]*)*)`/, Str::Backtick
|
155
|
-
rule /"/, Str::Double, :string
|
148
|
+
rule %r/(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?/i, Num::Float
|
149
|
+
rule %r/\d+e[+-]?\d+/i, Num::Float
|
150
|
+
rule %r/0[0-7]+/, Num::Oct
|
151
|
+
rule %r/0x[a-f0-9]+/i, Num::Hex
|
152
|
+
rule %r/\d+/, Num::Integer
|
153
|
+
rule %r/'([^'\\]*(?:\\.[^'\\]*)*)'/, Str::Single
|
154
|
+
rule %r/`([^`\\]*(?:\\.[^`\\]*)*)`/, Str::Backtick
|
155
|
+
rule %r/"/, Str::Double, :string
|
156
156
|
end
|
157
157
|
|
158
158
|
state :classname do
|
159
|
-
rule /\s+/, Text
|
160
|
-
rule /#{nsid}/, Name::Class, :pop!
|
159
|
+
rule %r/\s+/, Text
|
160
|
+
rule %r/#{nsid}/, Name::Class, :pop!
|
161
161
|
end
|
162
162
|
|
163
163
|
state :funcname do
|
164
|
-
rule /#{id}/, Name::Function, :pop!
|
164
|
+
rule %r/#{id}/, Name::Function, :pop!
|
165
165
|
end
|
166
166
|
|
167
167
|
state :string do
|
168
|
-
rule /"/, Str::Double, :pop!
|
169
|
-
rule /[^\\{$"]+/, Str::Double
|
170
|
-
rule /\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})/,
|
168
|
+
rule %r/"/, Str::Double, :pop!
|
169
|
+
rule %r/[^\\{$"]+/, Str::Double
|
170
|
+
rule %r/\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})/,
|
171
171
|
Str::Escape
|
172
|
-
rule /\$#{id}(\[\S+\]|->#{id})?/, Name::Variable
|
172
|
+
rule %r/\$#{id}(\[\S+\]|->#{id})?/, Name::Variable
|
173
173
|
|
174
|
-
rule /\{\$\{/, Str::Interpol, :interp_double
|
175
|
-
rule /\{(?=\$)/, Str::Interpol, :interp_single
|
176
|
-
rule /(\{)(\S+)(\})/ do
|
174
|
+
rule %r/\{\$\{/, Str::Interpol, :interp_double
|
175
|
+
rule %r/\{(?=\$)/, Str::Interpol, :interp_single
|
176
|
+
rule %r/(\{)(\S+)(\})/ do
|
177
177
|
groups Str::Interpol, Name::Variable, Str::Interpol
|
178
178
|
end
|
179
179
|
|
180
|
-
rule /[${\\]+/, Str::Double
|
180
|
+
rule %r/[${\\]+/, Str::Double
|
181
181
|
end
|
182
182
|
|
183
183
|
state :interp_double do
|
184
|
-
rule /\}\}/, Str::Interpol, :pop!
|
184
|
+
rule %r/\}\}/, Str::Interpol, :pop!
|
185
185
|
mixin :php
|
186
186
|
end
|
187
187
|
|
188
188
|
state :interp_single do
|
189
|
-
rule /\}/, Str::Interpol, :pop!
|
189
|
+
rule %r/\}/, Str::Interpol, :pop!
|
190
190
|
mixin :php
|
191
191
|
end
|
192
192
|
end
|
data/lib/rouge/lexers/plist.rb
CHANGED
@@ -6,41 +6,41 @@ module Rouge
|
|
6
6
|
desc 'plist'
|
7
7
|
tag 'plist'
|
8
8
|
aliases 'plist'
|
9
|
-
filenames
|
9
|
+
filenames '*.plist', '*.pbxproj'
|
10
10
|
|
11
11
|
mimetypes 'text/x-plist', 'application/x-plist'
|
12
12
|
|
13
13
|
state :whitespace do
|
14
|
-
rule /\s+/, Text::Whitespace
|
14
|
+
rule %r/\s+/, Text::Whitespace
|
15
15
|
end
|
16
16
|
|
17
17
|
state :root do
|
18
18
|
rule %r{//.*$}, Comment
|
19
19
|
rule %r{/\*.+?\*/}m, Comment
|
20
20
|
mixin :whitespace
|
21
|
-
rule /{/, Punctuation, :dictionary
|
22
|
-
rule /\(/, Punctuation, :array
|
23
|
-
rule /"([^"\\]|\\.)*"/, Literal::String::Double
|
24
|
-
rule /'([^'\\]|\\.)*'/, Literal::String::Single
|
25
|
-
rule /</, Punctuation, :data
|
26
|
-
rule %r{[\
|
21
|
+
rule %r/{/, Punctuation, :dictionary
|
22
|
+
rule %r/\(/, Punctuation, :array
|
23
|
+
rule %r/"([^"\\]|\\.)*"/, Literal::String::Double
|
24
|
+
rule %r/'([^'\\]|\\.)*'/, Literal::String::Single
|
25
|
+
rule %r/</, Punctuation, :data
|
26
|
+
rule %r{[\w$/:.-]+}, Literal
|
27
27
|
end
|
28
28
|
|
29
29
|
state :dictionary do
|
30
30
|
mixin :root
|
31
|
-
rule /[=;]/, Punctuation
|
32
|
-
rule /}/, Punctuation, :pop!
|
31
|
+
rule %r/[=;]/, Punctuation
|
32
|
+
rule %r/}/, Punctuation, :pop!
|
33
33
|
end
|
34
34
|
|
35
35
|
state :array do
|
36
36
|
mixin :root
|
37
|
-
rule /[,]/, Punctuation
|
38
|
-
rule /\)/, Punctuation, :pop!
|
37
|
+
rule %r/[,]/, Punctuation
|
38
|
+
rule %r/\)/, Punctuation, :pop!
|
39
39
|
end
|
40
40
|
|
41
41
|
state :data do
|
42
|
-
rule /[\h\s]+/, Literal::Number::Hex
|
43
|
-
rule />/, Punctuation, :pop!
|
42
|
+
rule %r/[\h\s]+/, Literal::Number::Hex
|
43
|
+
rule %r/>/, Punctuation, :pop!
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/rouge/lexers/pony.rb
CHANGED
@@ -40,28 +40,28 @@ module Rouge
|
|
40
40
|
)
|
41
41
|
|
42
42
|
state :whitespace do
|
43
|
-
rule
|
43
|
+
rule %r/\s+/m, Text
|
44
44
|
end
|
45
45
|
|
46
46
|
state :root do
|
47
47
|
mixin :whitespace
|
48
|
-
rule /"""/, Str::Doc, :docstring
|
48
|
+
rule %r/"""/, Str::Doc, :docstring
|
49
49
|
rule %r{//(.*?)\n}, Comment::Single
|
50
50
|
rule %r{/(\\\n)?[*](.|\n)*?[*](\\\n)?/}, Comment::Multiline
|
51
|
-
rule /"/, Str, :string
|
51
|
+
rule %r/"/, Str, :string
|
52
52
|
rule %r([~!%^&*+=\|?:<>/-]), Operator
|
53
|
-
rule /(true|false|NULL)\b/, Name::Constant
|
53
|
+
rule %r/(true|false|NULL)\b/, Name::Constant
|
54
54
|
rule %r{(?:[A-Z_][a-zA-Z0-9_]*)}, Name::Class
|
55
|
-
rule /[()\[\],.';]/, Punctuation
|
55
|
+
rule %r/[()\[\],.';]/, Punctuation
|
56
56
|
|
57
57
|
# Numbers
|
58
|
-
rule /0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float
|
59
|
-
rule /[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float
|
60
|
-
rule /\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float
|
61
|
-
rule /0[xX][0-9a-fA-F_]+/, Num::Hex
|
62
|
-
rule /(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer
|
58
|
+
rule %r/0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float
|
59
|
+
rule %r/[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float
|
60
|
+
rule %r/\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float
|
61
|
+
rule %r/0[xX][0-9a-fA-F_]+/, Num::Hex
|
62
|
+
rule %r/(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer
|
63
63
|
|
64
|
-
rule /[a-z_][a-z0-9_]*/io do |m|
|
64
|
+
rule %r/[a-z_][a-z0-9_]*/io do |m|
|
65
65
|
match = m[0]
|
66
66
|
|
67
67
|
if capabilities.include?(match)
|
@@ -77,17 +77,17 @@ module Rouge
|
|
77
77
|
end
|
78
78
|
|
79
79
|
state :string do
|
80
|
-
rule /"/, Str, :pop!
|
81
|
-
rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
|
82
|
-
rule /[^\\"\n]+/, Str
|
83
|
-
rule /\\\n/, Str
|
84
|
-
rule /\\/, Str # stray backslash
|
80
|
+
rule %r/"/, Str, :pop!
|
81
|
+
rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
|
82
|
+
rule %r/[^\\"\n]+/, Str
|
83
|
+
rule %r/\\\n/, Str
|
84
|
+
rule %r/\\/, Str # stray backslash
|
85
85
|
end
|
86
86
|
|
87
87
|
state :docstring do
|
88
|
-
rule /"""/, Str::Doc, :pop!
|
89
|
-
rule /\n/, Str::Doc
|
90
|
-
rule /./, Str::Doc
|
88
|
+
rule %r/"""/, Str::Doc, :pop!
|
89
|
+
rule %r/\n/, Str::Doc
|
90
|
+
rule %r/./, Str::Doc
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|