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/kotlin.rb
CHANGED
@@ -68,7 +68,7 @@ module Rouge
|
|
68
68
|
push :property
|
69
69
|
end
|
70
70
|
rule %r/\bfun\b/, Keyword
|
71
|
-
rule /\b(?:#{keywords.join('|')})\b/, Keyword
|
71
|
+
rule %r/\b(?:#{keywords.join('|')})\b/, Keyword
|
72
72
|
rule %r'^\s*\[.*?\]', Name::Attribute
|
73
73
|
rule %r'[^\S\n]+', Text
|
74
74
|
rule %r'\\\n', Text # line continuation
|
@@ -85,12 +85,12 @@ module Rouge
|
|
85
85
|
rule %r'"(\\\\|\\"|[^"\n])*["\n]'m, Str
|
86
86
|
rule %r"'\\.'|'[^\\]'", Str::Char
|
87
87
|
rule %r"[0-9](\.[0-9]+)?([eE][+-][0-9]+)?[flFL]?|0[xX][0-9a-fA-F]+[Ll]?", Num
|
88
|
-
rule /@#{id}/, Name::Decorator
|
88
|
+
rule %r/@#{id}/, Name::Decorator
|
89
89
|
rule id, Name
|
90
90
|
end
|
91
91
|
|
92
92
|
state :package do
|
93
|
-
rule /\S+/, Name::Namespace, :pop!
|
93
|
+
rule %r/\S+/, Name::Namespace, :pop!
|
94
94
|
end
|
95
95
|
|
96
96
|
state :class do
|
data/lib/rouge/lexers/lasso.rb
CHANGED
@@ -39,7 +39,7 @@ module Rouge
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Load Lasso keywords from separate YML file
|
42
|
-
@keywords = ::YAML.load_file(
|
42
|
+
@keywords = ::YAML.load_file(File.join(__dir__, 'lasso/keywords.yml')).tap do |h|
|
43
43
|
h.each do |k,v|
|
44
44
|
h[k] = Set.new v
|
45
45
|
end
|
@@ -48,23 +48,23 @@ module Rouge
|
|
48
48
|
id = /[a-z_][\w.]*/i
|
49
49
|
|
50
50
|
state :root do
|
51
|
-
rule /^#![ \S]+lasso9\b/, Comment::Preproc, :lasso
|
51
|
+
rule %r/^#![ \S]+lasso9\b/, Comment::Preproc, :lasso
|
52
52
|
rule(/(?=\[|<)/) { push :delimiters }
|
53
|
-
rule /\s+/, Text::Whitespace
|
53
|
+
rule %r/\s+/, Text::Whitespace
|
54
54
|
rule(//) { push :delimiters; push :lassofile }
|
55
55
|
end
|
56
56
|
|
57
57
|
state :delimiters do
|
58
|
-
rule /\[no_square_brackets\]/, Comment::Preproc, :nosquarebrackets
|
59
|
-
rule /\[noprocess\]/, Comment::Preproc, :noprocess
|
60
|
-
rule /\[/, Comment::Preproc, :squarebrackets
|
61
|
-
rule /<\?(lasso(script)?|=)/i, Comment::Preproc, :anglebrackets
|
58
|
+
rule %r/\[no_square_brackets\]/, Comment::Preproc, :nosquarebrackets
|
59
|
+
rule %r/\[noprocess\]/, Comment::Preproc, :noprocess
|
60
|
+
rule %r/\[/, Comment::Preproc, :squarebrackets
|
61
|
+
rule %r/<\?(lasso(script)?|=)/i, Comment::Preproc, :anglebrackets
|
62
62
|
rule(/([^\[<]|<!--.*?-->|<(script|style).*?\2>|<(?!\?(lasso(script)?|=)))+/im) { delegate parent }
|
63
63
|
end
|
64
64
|
|
65
65
|
state :nosquarebrackets do
|
66
|
-
rule /\[noprocess\]/, Comment::Preproc, :noprocess
|
67
|
-
rule /<\?(lasso(script)?|=)/i, Comment::Preproc, :anglebrackets
|
66
|
+
rule %r/\[noprocess\]/, Comment::Preproc, :noprocess
|
67
|
+
rule %r/<\?(lasso(script)?|=)/i, Comment::Preproc, :anglebrackets
|
68
68
|
rule(/([^\[<]|<!--.*?-->|<(script|style).*?\2>|<(?!\?(lasso(script)?|=))|\[(?!noprocess))+/im) { delegate parent }
|
69
69
|
end
|
70
70
|
|
@@ -74,22 +74,22 @@ module Rouge
|
|
74
74
|
end
|
75
75
|
|
76
76
|
state :squarebrackets do
|
77
|
-
rule /\]/, Comment::Preproc, :pop!
|
77
|
+
rule %r/\]/, Comment::Preproc, :pop!
|
78
78
|
mixin :lasso
|
79
79
|
end
|
80
80
|
|
81
81
|
state :anglebrackets do
|
82
|
-
rule /\?>/, Comment::Preproc, :pop!
|
82
|
+
rule %r/\?>/, Comment::Preproc, :pop!
|
83
83
|
mixin :lasso
|
84
84
|
end
|
85
85
|
|
86
86
|
state :lassofile do
|
87
|
-
rule /\]|\?>/, Comment::Preproc, :pop!
|
87
|
+
rule %r/\]|\?>/, Comment::Preproc, :pop!
|
88
88
|
mixin :lasso
|
89
89
|
end
|
90
90
|
|
91
91
|
state :whitespacecomments do
|
92
|
-
rule /\s+/, Text
|
92
|
+
rule %r/\s+/, Text
|
93
93
|
rule %r(//.*?\n), Comment::Single
|
94
94
|
rule %r(/\*\*!.*?\*/)m, Comment::Doc
|
95
95
|
rule %r(/\*.*?\*/)m, Comment::Multiline
|
@@ -99,43 +99,43 @@ module Rouge
|
|
99
99
|
mixin :whitespacecomments
|
100
100
|
|
101
101
|
# literals
|
102
|
-
rule /\d*\.\d+(e[+-]?\d+)?/i, Num::Float
|
103
|
-
rule /0x[\da-f]+/i, Num::Hex
|
104
|
-
rule /\d+/, Num::Integer
|
105
|
-
rule /(infinity|NaN)\b/i, Num
|
106
|
-
rule /'[^'\\]*(\\.[^'\\]*)*'/m, Str::Single
|
107
|
-
rule /"[^"\\]*(\\.[^"\\]*)*"/m, Str::Double
|
108
|
-
rule /`[^`]*`/m, Str::Backtick
|
102
|
+
rule %r/\d*\.\d+(e[+-]?\d+)?/i, Num::Float
|
103
|
+
rule %r/0x[\da-f]+/i, Num::Hex
|
104
|
+
rule %r/\d+/, Num::Integer
|
105
|
+
rule %r/(infinity|NaN)\b/i, Num
|
106
|
+
rule %r/'[^'\\]*(\\.[^'\\]*)*'/m, Str::Single
|
107
|
+
rule %r/"[^"\\]*(\\.[^"\\]*)*"/m, Str::Double
|
108
|
+
rule %r/`[^`]*`/m, Str::Backtick
|
109
109
|
|
110
110
|
# names
|
111
|
-
rule /\$#{id}/, Name::Variable
|
112
|
-
rule /#(#{id}|\d+\b)/, Name::Variable::Instance
|
113
|
-
rule /(\.\s*)('#{id}')/ do
|
111
|
+
rule %r/\$#{id}/, Name::Variable
|
112
|
+
rule %r/#(#{id}|\d+\b)/, Name::Variable::Instance
|
113
|
+
rule %r/(\.\s*)('#{id}')/ do
|
114
114
|
groups Name::Builtin::Pseudo, Name::Variable::Class
|
115
115
|
end
|
116
|
-
rule /(self)(\s*->\s*)('#{id}')/i do
|
116
|
+
rule %r/(self)(\s*->\s*)('#{id}')/i do
|
117
117
|
groups Name::Builtin::Pseudo, Operator, Name::Variable::Class
|
118
118
|
end
|
119
|
-
rule /(\.\.?\s*)(#{id}(=(?!=))?)/ do
|
119
|
+
rule %r/(\.\.?\s*)(#{id}(=(?!=))?)/ do
|
120
120
|
groups Name::Builtin::Pseudo, Name::Other
|
121
121
|
end
|
122
|
-
rule /(->\\?\s*|&\s*)(#{id}(=(?!=))?)/ do
|
122
|
+
rule %r/(->\\?\s*|&\s*)(#{id}(=(?!=))?)/ do
|
123
123
|
groups Operator, Name::Other
|
124
124
|
end
|
125
|
-
rule /(?<!->)(self|inherited|currentcapture|givenblock)\b/i, Name::Builtin::Pseudo
|
126
|
-
rule /-(?!infinity)#{id}/i, Name::Attribute
|
127
|
-
rule /::\s*#{id}/, Name::Label
|
128
|
-
rule /error_((code|msg)_\w+|adderror|columnrestriction|databaseconnectionunavailable|databasetimeout|deleteerror|fieldrestriction|filenotfound|invaliddatabase|invalidpassword|invalidusername|modulenotfound|noerror|nopermission|outofmemory|reqcolumnmissing|reqfieldmissing|requiredcolumnmissing|requiredfieldmissing|updateerror)/i, Name::Exception
|
125
|
+
rule %r/(?<!->)(self|inherited|currentcapture|givenblock)\b/i, Name::Builtin::Pseudo
|
126
|
+
rule %r/-(?!infinity)#{id}/i, Name::Attribute
|
127
|
+
rule %r/::\s*#{id}/, Name::Label
|
128
|
+
rule %r/error_((code|msg)_\w+|adderror|columnrestriction|databaseconnectionunavailable|databasetimeout|deleteerror|fieldrestriction|filenotfound|invaliddatabase|invalidpassword|invalidusername|modulenotfound|noerror|nopermission|outofmemory|reqcolumnmissing|reqfieldmissing|requiredcolumnmissing|requiredfieldmissing|updateerror)/i, Name::Exception
|
129
129
|
|
130
130
|
# definitions
|
131
|
-
rule /(define)(\s+)(#{id})(\s*=>\s*)(type|trait|thread)\b/i do
|
131
|
+
rule %r/(define)(\s+)(#{id})(\s*=>\s*)(type|trait|thread)\b/i do
|
132
132
|
groups Keyword::Declaration, Text, Name::Class, Operator, Keyword
|
133
133
|
end
|
134
134
|
rule %r((define)(\s+)(#{id})(\s*->\s*)(#{id}=?|[-+*/%]))i do
|
135
135
|
groups Keyword::Declaration, Text, Name::Class, Operator, Name::Function
|
136
136
|
push :signature
|
137
137
|
end
|
138
|
-
rule /(define)(\s+)(#{id})/i do
|
138
|
+
rule %r/(define)(\s+)(#{id})/i do
|
139
139
|
groups Keyword::Declaration, Text, Name::Function
|
140
140
|
push :signature
|
141
141
|
end
|
@@ -143,25 +143,25 @@ module Rouge
|
|
143
143
|
groups Keyword, Text, Name::Function
|
144
144
|
push :signature
|
145
145
|
end
|
146
|
-
rule /(public|protected|private|provide)(\s+)(#{id})/i do
|
146
|
+
rule %r/(public|protected|private|provide)(\s+)(#{id})/i do
|
147
147
|
groups Keyword, Text, Name::Function
|
148
148
|
end
|
149
149
|
|
150
150
|
# keywords
|
151
|
-
rule /(true|false|none|minimal|full|all|void)\b/i, Keyword::Constant
|
152
|
-
rule /(local|var|variable|global|data(?=\s))\b/i, Keyword::Declaration
|
153
|
-
rule /(array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray)\b/i, Keyword::Type
|
154
|
-
rule /(#{id})(\s+)(in)\b/i do
|
151
|
+
rule %r/(true|false|none|minimal|full|all|void)\b/i, Keyword::Constant
|
152
|
+
rule %r/(local|var|variable|global|data(?=\s))\b/i, Keyword::Declaration
|
153
|
+
rule %r/(array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray)\b/i, Keyword::Type
|
154
|
+
rule %r/(#{id})(\s+)(in)\b/i do
|
155
155
|
groups Name, Text, Keyword
|
156
156
|
end
|
157
|
-
rule /(let|into)(\s+)(#{id})/i do
|
157
|
+
rule %r/(let|into)(\s+)(#{id})/i do
|
158
158
|
groups Keyword, Text, Name
|
159
159
|
end
|
160
160
|
|
161
161
|
# other
|
162
|
-
rule /,/, Punctuation, :commamember
|
163
|
-
rule /(and|or|not)\b/i, Operator::Word
|
164
|
-
rule /(#{id})(\s*::\s*#{id})?(\s*=(?!=|>))/ do
|
162
|
+
rule %r/,/, Punctuation, :commamember
|
163
|
+
rule %r/(and|or|not)\b/i, Operator::Word
|
164
|
+
rule %r/(#{id})(\s*::\s*#{id})?(\s*=(?!=|>))/ do
|
165
165
|
groups Name, Name::Label, Operator
|
166
166
|
end
|
167
167
|
|
@@ -183,31 +183,31 @@ module Rouge
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
rule /(=)(n?bw|n?ew|n?cn|lte?|gte?|n?eq|n?rx|ft)\b/i do
|
186
|
+
rule %r/(=)(n?bw|n?ew|n?cn|lte?|gte?|n?eq|n?rx|ft)\b/i do
|
187
187
|
groups Operator, Operator::Word
|
188
188
|
end
|
189
189
|
rule %r(:=|[-+*/%=<>&|!?\\]+), Operator
|
190
|
-
rule /[{}():;,@^]/, Punctuation
|
190
|
+
rule %r/[{}():;,@^]/, Punctuation
|
191
191
|
end
|
192
192
|
|
193
193
|
state :signature do
|
194
|
-
rule /\=>/, Operator, :pop!
|
195
|
-
rule /\)/, Punctuation, :pop!
|
196
|
-
rule /[(,]/, Punctuation, :parameter
|
194
|
+
rule %r/\=>/, Operator, :pop!
|
195
|
+
rule %r/\)/, Punctuation, :pop!
|
196
|
+
rule %r/[(,]/, Punctuation, :parameter
|
197
197
|
mixin :lasso
|
198
198
|
end
|
199
199
|
|
200
200
|
state :parameter do
|
201
|
-
rule /\)/, Punctuation, :pop!
|
202
|
-
rule /-?#{id}/, Name::Attribute, :pop!
|
203
|
-
rule /\.\.\./, Name::Builtin::Pseudo
|
201
|
+
rule %r/\)/, Punctuation, :pop!
|
202
|
+
rule %r/-?#{id}/, Name::Attribute, :pop!
|
203
|
+
rule %r/\.\.\./, Name::Builtin::Pseudo
|
204
204
|
mixin :lasso
|
205
205
|
end
|
206
206
|
|
207
207
|
state :commamember do
|
208
208
|
rule %r((#{id}=?|[-+*/%])(?=\s*(\(([^()]*\([^()]*\))*[^\)]*\)\s*)?(::[\w.\s]+)?=>)), Name::Function, :signature
|
209
209
|
mixin :whitespacecomments
|
210
|
-
rule //, Text, :pop!
|
210
|
+
rule %r//, Text, :pop!
|
211
211
|
end
|
212
212
|
|
213
213
|
end
|
data/lib/rouge/lexers/liquid.rb
CHANGED
@@ -10,67 +10,67 @@ module Rouge
|
|
10
10
|
filenames '*.liquid'
|
11
11
|
|
12
12
|
state :root do
|
13
|
-
rule /[^\{]+/, Text
|
13
|
+
rule %r/[^\{]+/, Text
|
14
14
|
|
15
|
-
rule /(\{%)(\s*)/ do
|
15
|
+
rule %r/(\{%)(\s*)/ do
|
16
16
|
groups Punctuation, Text::Whitespace
|
17
17
|
push :tag_or_block
|
18
18
|
end
|
19
19
|
|
20
|
-
rule /(\{\{)(\s*)/ do
|
20
|
+
rule %r/(\{\{)(\s*)/ do
|
21
21
|
groups Punctuation, Text::Whitespace
|
22
22
|
push :output
|
23
23
|
end
|
24
24
|
|
25
|
-
rule /\{/, Text
|
25
|
+
rule %r/\{/, Text
|
26
26
|
end
|
27
27
|
|
28
28
|
state :tag_or_block do
|
29
29
|
# builtin logic blocks
|
30
|
-
rule /(if|unless|elsif|case)(?=\s+)/, Keyword::Reserved, :condition
|
30
|
+
rule %r/(if|unless|elsif|case)(?=\s+)/, Keyword::Reserved, :condition
|
31
31
|
|
32
|
-
rule /(when)(\s+)/ do
|
32
|
+
rule %r/(when)(\s+)/ do
|
33
33
|
groups Keyword::Reserved, Text::Whitespace
|
34
34
|
push :when
|
35
35
|
end
|
36
36
|
|
37
|
-
rule /(else)(\s*)(%\})/ do
|
37
|
+
rule %r/(else)(\s*)(%\})/ do
|
38
38
|
groups Keyword::Reserved, Text::Whitespace, Punctuation
|
39
39
|
pop!
|
40
40
|
end
|
41
41
|
|
42
42
|
# other builtin blocks
|
43
|
-
rule /(capture)(\s+)([^\s%]+)(\s*)(%\})/ do
|
43
|
+
rule %r/(capture)(\s+)([^\s%]+)(\s*)(%\})/ do
|
44
44
|
groups Name::Tag, Text::Whitespace, Name::Attribute, Text::Whitespace, Punctuation
|
45
45
|
pop!
|
46
46
|
end
|
47
47
|
|
48
|
-
rule /(comment)(\s*)(%\})/ do
|
48
|
+
rule %r/(comment)(\s*)(%\})/ do
|
49
49
|
groups Name::Tag, Text::Whitespace, Punctuation
|
50
50
|
push :comment
|
51
51
|
end
|
52
52
|
|
53
|
-
rule /(raw)(\s*)(%\})/ do
|
53
|
+
rule %r/(raw)(\s*)(%\})/ do
|
54
54
|
groups Name::Tag, Text::Whitespace, Punctuation
|
55
55
|
push :raw
|
56
56
|
end
|
57
57
|
|
58
|
-
rule /assign/, Name::Tag, :assign
|
59
|
-
rule /include/, Name::Tag, :include
|
58
|
+
rule %r/assign/, Name::Tag, :assign
|
59
|
+
rule %r/include/, Name::Tag, :include
|
60
60
|
|
61
61
|
# end of block
|
62
|
-
rule /(end(case|unless|if))(\s*)(%\})/ do
|
63
|
-
groups Keyword::Reserved,
|
62
|
+
rule %r/(end(?:case|unless|if))(\s*)(%\})/ do
|
63
|
+
groups Keyword::Reserved, Text::Whitespace, Punctuation
|
64
64
|
pop!
|
65
65
|
end
|
66
66
|
|
67
|
-
rule /(end([^\s%]+))(\s*)(%\})/ do
|
68
|
-
groups Name::Tag,
|
67
|
+
rule %r/(end(?:[^\s%]+))(\s*)(%\})/ do
|
68
|
+
groups Name::Tag, Text::Whitespace, Punctuation
|
69
69
|
pop!
|
70
70
|
end
|
71
71
|
|
72
72
|
# builtin tags
|
73
|
-
rule /(cycle)(\s+)(([^\s:]*)(:))?(\s*)/ do |m|
|
73
|
+
rule %r/(cycle)(\s+)(([^\s:]*)(:))?(\s*)/ do |m|
|
74
74
|
token Name::Tag, m[1]
|
75
75
|
token Text::Whitespace, m[2]
|
76
76
|
|
@@ -89,7 +89,7 @@ module Rouge
|
|
89
89
|
end
|
90
90
|
|
91
91
|
# other tags or blocks
|
92
|
-
rule /([^\s%]+)(\s*)/ do
|
92
|
+
rule %r/([^\s%]+)(\s*)/ do
|
93
93
|
groups Name::Tag, Text::Whitespace
|
94
94
|
push :tag_markup
|
95
95
|
end
|
@@ -99,8 +99,8 @@ module Rouge
|
|
99
99
|
mixin :whitespace
|
100
100
|
mixin :generic
|
101
101
|
|
102
|
-
rule /\}\}/, Punctuation, :pop!
|
103
|
-
rule /\|/, Punctuation, :filters
|
102
|
+
rule %r/\}\}/, Punctuation, :pop!
|
103
|
+
rule %r/\|/, Punctuation, :filters
|
104
104
|
end
|
105
105
|
|
106
106
|
state :filters do
|
@@ -108,14 +108,14 @@ module Rouge
|
|
108
108
|
|
109
109
|
rule(/\}\}/) { token Punctuation; reset_stack }
|
110
110
|
|
111
|
-
rule /([^\s\|:]+)(:?)(\s*)/ do
|
111
|
+
rule %r/([^\s\|:]+)(:?)(\s*)/ do
|
112
112
|
groups Name::Function, Punctuation, Text::Whitespace
|
113
113
|
push :filter_markup
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
state :filter_markup do
|
118
|
-
rule /\|/, Punctuation, :pop!
|
118
|
+
rule %r/\|/, Punctuation, :pop!
|
119
119
|
|
120
120
|
mixin :end_of_tag
|
121
121
|
mixin :end_of_block
|
@@ -126,13 +126,13 @@ module Rouge
|
|
126
126
|
mixin :end_of_block
|
127
127
|
mixin :whitespace
|
128
128
|
|
129
|
-
rule /([=!><]=?)/, Operator
|
129
|
+
rule %r/([=!><]=?)/, Operator
|
130
130
|
|
131
|
-
rule /\b((!)|(not\b))/ do
|
132
|
-
groups
|
131
|
+
rule %r/\b(?:(!)|(not\b))/ do
|
132
|
+
groups Operator, Operator::Word
|
133
133
|
end
|
134
134
|
|
135
|
-
rule /(contains)/, Operator::Word
|
135
|
+
rule %r/(contains)/, Operator::Word
|
136
136
|
|
137
137
|
mixin :generic
|
138
138
|
mixin :whitespace
|
@@ -145,12 +145,12 @@ module Rouge
|
|
145
145
|
end
|
146
146
|
|
147
147
|
state :operator do
|
148
|
-
rule /(\s*)((
|
149
|
-
groups Text::Whitespace, Operator,
|
148
|
+
rule %r/(\s*)((?:=|!|>|<)=?)(\s*)/ do
|
149
|
+
groups Text::Whitespace, Operator, Text::Whitespace
|
150
150
|
pop!
|
151
151
|
end
|
152
152
|
|
153
|
-
rule /(\s*)(\bcontains\b)(\s*)/ do
|
153
|
+
rule %r/(\s*)(\bcontains\b)(\s*)/ do
|
154
154
|
groups Text::Whitespace, Operator::Word, Text::Whitespace
|
155
155
|
pop!
|
156
156
|
end
|
@@ -169,29 +169,29 @@ module Rouge
|
|
169
169
|
mixin :whitespace
|
170
170
|
mixin :string
|
171
171
|
|
172
|
-
rule /([^\s=:]+)(\s*)(=|:)/ do
|
172
|
+
rule %r/([^\s=:]+)(\s*)(=|:)/ do
|
173
173
|
groups Name::Attribute, Text::Whitespace, Operator
|
174
174
|
end
|
175
175
|
|
176
|
-
rule /(\{\{)(\s*)([^\s\}])(\s*)(\}\})/ do
|
177
|
-
groups Punctuation, Text::Whitespace,
|
176
|
+
rule %r/(\{\{)(\s*)([^\s\}])(\s*)(\}\})/ do
|
177
|
+
groups Punctuation, Text::Whitespace, Text, Text::Whitespace, Punctuation
|
178
178
|
end
|
179
179
|
|
180
180
|
mixin :number
|
181
181
|
mixin :keyword
|
182
182
|
|
183
|
-
rule /,/, Punctuation
|
183
|
+
rule %r/,/, Punctuation
|
184
184
|
end
|
185
185
|
|
186
186
|
state :default_param_markup do
|
187
187
|
mixin :param_markup
|
188
|
-
rule /./, Text
|
188
|
+
rule %r/./, Text
|
189
189
|
end
|
190
190
|
|
191
191
|
state :variable_param_markup do
|
192
192
|
mixin :param_markup
|
193
193
|
mixin :variable
|
194
|
-
rule /./, Text
|
194
|
+
rule %r/./, Text
|
195
195
|
end
|
196
196
|
|
197
197
|
state :tag_markup do
|
@@ -206,27 +206,27 @@ module Rouge
|
|
206
206
|
|
207
207
|
# states for different values types
|
208
208
|
state :keyword do
|
209
|
-
rule /\b(false|true)\b/, Keyword::Constant
|
209
|
+
rule %r/\b(false|true)\b/, Keyword::Constant
|
210
210
|
end
|
211
211
|
|
212
212
|
state :variable do
|
213
|
-
rule /\.(?=\w)/, Punctuation
|
214
|
-
rule /[a-zA-Z_]\w*\??/, Name::Variable
|
213
|
+
rule %r/\.(?=\w)/, Punctuation
|
214
|
+
rule %r/[a-zA-Z_]\w*\??/, Name::Variable
|
215
215
|
end
|
216
216
|
|
217
217
|
state :string do
|
218
|
-
rule /'[^']*'/, Str::Single
|
219
|
-
rule /"[^"]*"/, Str::Double
|
218
|
+
rule %r/'[^']*'/, Str::Single
|
219
|
+
rule %r/"[^"]*"/, Str::Double
|
220
220
|
end
|
221
221
|
|
222
222
|
state :number do
|
223
|
-
rule /\d+\.\d+/, Num::Float
|
224
|
-
rule /\d+/, Num::Integer
|
223
|
+
rule %r/\d+\.\d+/, Num::Float
|
224
|
+
rule %r/\d+/, Num::Integer
|
225
225
|
end
|
226
226
|
|
227
227
|
state :array_index do
|
228
|
-
rule /\[/, Punctuation
|
229
|
-
rule /\]/, Punctuation
|
228
|
+
rule %r/\[/, Punctuation
|
229
|
+
rule %r/\]/, Punctuation
|
230
230
|
end
|
231
231
|
|
232
232
|
state :generic do
|
@@ -238,38 +238,38 @@ module Rouge
|
|
238
238
|
end
|
239
239
|
|
240
240
|
state :whitespace do
|
241
|
-
rule /[ \t]+/, Text::Whitespace
|
241
|
+
rule %r/[ \t]+/, Text::Whitespace
|
242
242
|
end
|
243
243
|
|
244
244
|
state :comment do
|
245
|
-
rule /(\{%)(\s*)(endcomment)(\s*)(%\})/ do
|
245
|
+
rule %r/(\{%)(\s*)(endcomment)(\s*)(%\})/ do
|
246
246
|
groups Punctuation, Text::Whitespace, Name::Tag, Text::Whitespace, Punctuation
|
247
247
|
reset_stack
|
248
248
|
end
|
249
249
|
|
250
|
-
rule /./, Comment
|
250
|
+
rule %r/./, Comment
|
251
251
|
end
|
252
252
|
|
253
253
|
state :raw do
|
254
|
-
rule /[^\{]+/, Text
|
254
|
+
rule %r/[^\{]+/, Text
|
255
255
|
|
256
|
-
rule /(\{%)(\s*)(endraw)(\s*)(%\})/ do
|
256
|
+
rule %r/(\{%)(\s*)(endraw)(\s*)(%\})/ do
|
257
257
|
groups Punctuation, Text::Whitespace, Name::Tag, Text::Whitespace, Punctuation
|
258
258
|
reset_stack
|
259
259
|
end
|
260
260
|
|
261
|
-
rule /\{/, Text
|
261
|
+
rule %r/\{/, Text
|
262
262
|
end
|
263
263
|
|
264
264
|
state :assign do
|
265
265
|
mixin :whitespace
|
266
266
|
mixin :end_of_block
|
267
267
|
|
268
|
-
rule /(\s*)(=)(\s*)/ do
|
268
|
+
rule %r/(\s*)(=)(\s*)/ do
|
269
269
|
groups Text::Whitespace, Operator, Text::Whitespace
|
270
270
|
end
|
271
271
|
|
272
|
-
rule /\|/, Punctuation, :filters
|
272
|
+
rule %r/\|/, Punctuation, :filters
|
273
273
|
|
274
274
|
mixin :generic
|
275
275
|
end
|
@@ -277,7 +277,7 @@ module Rouge
|
|
277
277
|
state :include do
|
278
278
|
mixin :whitespace
|
279
279
|
|
280
|
-
rule /([^\.]+)(\.)(html|liquid)/ do
|
280
|
+
rule %r/([^\.]+)(\.)(html|liquid)/ do
|
281
281
|
groups Name::Attribute, Punctuation, Name::Attribute
|
282
282
|
end
|
283
283
|
|