rouge 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rouge/cli.rb +4 -0
- data/lib/rouge/demos/glsl +14 -0
- data/lib/rouge/demos/json-doc +1 -0
- data/lib/rouge/demos/objective_c +2 -0
- data/lib/rouge/lexer.rb +1 -1
- data/lib/rouge/lexers/cpp.rb +2 -1
- data/lib/rouge/lexers/diff.rb +13 -20
- data/lib/rouge/lexers/elixir.rb +1 -0
- data/lib/rouge/lexers/glsl.rb +135 -0
- data/lib/rouge/lexers/javascript.rb +46 -9
- data/lib/rouge/lexers/liquid.rb +11 -6
- data/lib/rouge/lexers/objective_c.rb +7 -0
- data/lib/rouge/lexers/php.rb +1 -1
- data/lib/rouge/lexers/ruby.rb +2 -2
- data/lib/rouge/lexers/sass/common.rb +7 -1
- data/lib/rouge/lexers/slim.rb +9 -6
- data/lib/rouge/lexers/swift.rb +5 -1
- data/lib/rouge/token.rb +1 -1
- data/lib/rouge/version.rb +1 -1
- data/rouge.gemspec +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adb7cda324b7dd6e49be5dccd1e4ca75bff7fc2f
|
4
|
+
data.tar.gz: e3ebe723270949c77cc11d16523ae58884527b8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26279e371f5367170cd0767402211252e635929e836219b3c278dd133eee45b9e22f42d06388ce8dbc77a58f6ec016333fd7ec8ca19d79f7cdd2a164ea172bc8
|
7
|
+
data.tar.gz: 21183cbc27313fccb93ef5a13abfdf0f81e9c4ba102dbd5f42422901775f0f6cae367b77443a543a9e385929b427e09fba998bc953d715600f92710253af2c18
|
data/lib/rouge/cli.rb
CHANGED
@@ -165,6 +165,10 @@ module Rouge
|
|
165
165
|
yield %[ based on --mimetype, the filename, and the]
|
166
166
|
yield %[ file contents.]
|
167
167
|
yield %[]
|
168
|
+
yield %[--formatter|-f <opts> specify the output formatter to use.]
|
169
|
+
yield %[ If not provided, rougify will default to]
|
170
|
+
yield %[ terminal256.]
|
171
|
+
yield %[]
|
168
172
|
yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
|
169
173
|
yield %[]
|
170
174
|
yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
|
@@ -0,0 +1 @@
|
|
1
|
+
{ "one": 1, "two": 2, "null": null, "simple": true } // a simple json object
|
data/lib/rouge/demos/objective_c
CHANGED
data/lib/rouge/lexer.rb
CHANGED
data/lib/rouge/lexers/cpp.rb
CHANGED
data/lib/rouge/lexers/diff.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# -*- coding: utf-8 -*- #
|
2
|
-
|
3
1
|
module Rouge
|
4
2
|
module Lexers
|
5
3
|
class Diff < RegexLexer
|
6
|
-
title
|
7
|
-
desc
|
4
|
+
title 'diff'
|
5
|
+
desc 'Lexes unified diffs or patches'
|
8
6
|
|
9
7
|
tag 'diff'
|
10
8
|
aliases 'patch', 'udiff'
|
@@ -15,26 +13,21 @@ module Rouge
|
|
15
13
|
return 1 if text.start_with?('Index: ')
|
16
14
|
return 1 if text.start_with?('diff ')
|
17
15
|
|
16
|
+
# TODO: Have a look at pygments here, seems better
|
18
17
|
return 0.9 if text =~ /\A---.*?\n\+\+\+/m
|
19
18
|
end
|
20
19
|
|
21
|
-
state :header do
|
22
|
-
rule /^diff .*?\n(?=---|\+\+\+)/m, Generic::Heading
|
23
|
-
rule /^--- .*?\n/, Generic::Deleted
|
24
|
-
rule /^\+\+\+ .*?\n/, Generic::Inserted
|
25
|
-
end
|
26
|
-
|
27
|
-
state :diff do
|
28
|
-
rule /@@ -\d+,\d+ \+\d+,\d+ @@.*?\n/, Generic::Heading
|
29
|
-
rule /^\+.*?\n/, Generic::Inserted
|
30
|
-
rule /^-.*?\n/, Generic::Deleted
|
31
|
-
rule /^ .*?\n/, Text
|
32
|
-
rule /^.*?\n/, Error
|
33
|
-
end
|
34
|
-
|
35
20
|
state :root do
|
36
|
-
|
37
|
-
|
21
|
+
rule(/^ .*\n/, Text)
|
22
|
+
rule(/^\+.*\n/, Generic::Inserted)
|
23
|
+
# Do not highlight the delimiter line
|
24
|
+
# before the diffstat in email patches.
|
25
|
+
rule(/^-+ .*\n/, Generic::Deleted)
|
26
|
+
rule(/^!.*\n/, Generic::Strong)
|
27
|
+
rule(/^@.*\n/, Generic::Subheading)
|
28
|
+
rule(/^([Ii]ndex|diff).*\n/, Generic::Heading)
|
29
|
+
rule(/^=.*\n/, Generic::Heading)
|
30
|
+
rule(/.*\n/, Text)
|
38
31
|
end
|
39
32
|
end
|
40
33
|
end
|
data/lib/rouge/lexers/elixir.rb
CHANGED
@@ -0,0 +1,135 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
load_const :C, 'c.rb'
|
6
|
+
|
7
|
+
# This file defines the GLSL language lexer to the Rouge
|
8
|
+
# syntax highlighter.
|
9
|
+
#
|
10
|
+
# Author: Sri Harsha Chilakapati
|
11
|
+
class Glsl < C
|
12
|
+
tag 'glsl'
|
13
|
+
filenames '*.glsl', '*.frag', '*.vert', '*.geom', '*.fs', '*.vs', '*.gs', '*.shader'
|
14
|
+
mimetypes 'x-shader/x-vertex', 'x-shader/x-fragment', 'x-shader/x-geometry'
|
15
|
+
|
16
|
+
title "GLSL"
|
17
|
+
desc "The GLSL shader language"
|
18
|
+
|
19
|
+
# optional comment or whitespace
|
20
|
+
ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
|
21
|
+
id = /[a-zA-Z_][a-zA-Z0-9_]*/
|
22
|
+
|
23
|
+
def self.keywords
|
24
|
+
@keywords ||= Set.new %w(
|
25
|
+
attribute const uniform varying
|
26
|
+
layout
|
27
|
+
centroid flat smooth noperspective
|
28
|
+
patch sample
|
29
|
+
break continue do for while switch case default
|
30
|
+
if else
|
31
|
+
subroutine
|
32
|
+
in out inout
|
33
|
+
invariant
|
34
|
+
discard return struct precision
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.keywords_type
|
39
|
+
@keywords_type ||= Set.new %w(
|
40
|
+
float double int void bool true false
|
41
|
+
lowp mediump highp
|
42
|
+
mat2 mat3 mat4 dmat2 dmat3 dmat4
|
43
|
+
mat2x2 mat2x3 mat2x4 dmat2x2 dmat2x3 dmat2x4
|
44
|
+
mat3x2 mat3x3 mat3x4 dmat3x2 dmat3x3 dmat3x4
|
45
|
+
mat4x2 mat4x3 mat4x4 dmat4x2 dmat4x3 dmat4x4
|
46
|
+
vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 dvec2 dvec3 dvec4
|
47
|
+
uint uvec2 uvec3 uvec4
|
48
|
+
sampler1D sampler2D sampler3D samplerCube
|
49
|
+
sampler1DShadow sampler2DShadow samplerCubeShadow
|
50
|
+
sampler1DArray sampler2DArray
|
51
|
+
sampler1DArrayShadow sampler2DArrayShadow
|
52
|
+
isampler1D isampler2D isampler3D isamplerCube
|
53
|
+
isampler1DArray isampler2DArray
|
54
|
+
usampler1D usampler2D usampler3D usamplerCube
|
55
|
+
usampler1DArray usampler2DArray
|
56
|
+
sampler2DRect sampler2DRectShadow isampler2DRect usampler2DRect
|
57
|
+
samplerBuffer isamplerBuffer usamplerBuffer
|
58
|
+
sampler2DMS isampler2DMS usampler2DMS
|
59
|
+
sampler2DMSArray isampler2DMSArray usampler2DMSArray
|
60
|
+
samplerCubeArray samplerCubeArrayShadow isamplerCubeArray usamplerCubeArray
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.reserved
|
65
|
+
@reserved ||= Set.new %w(
|
66
|
+
common partition active
|
67
|
+
asm
|
68
|
+
class union enum typedef template this packed
|
69
|
+
goto
|
70
|
+
inline noinline volatile public static extern external interface
|
71
|
+
long short half fixed unsigned superp
|
72
|
+
input output
|
73
|
+
hvec2 hvec3 hvec4 fvec2 fvec3 fvec4
|
74
|
+
sampler3DRect
|
75
|
+
filter
|
76
|
+
image1D image2D image3D imageCube
|
77
|
+
iimage1D iimage2D iimage3D iimageCube
|
78
|
+
uimage1D uimage2D uimage3D uimageCube
|
79
|
+
image1DArray image2DArray
|
80
|
+
iimage1DArray iimage2DArray uimage1DArray uimage2DArray
|
81
|
+
image1DShadow image2DShadow
|
82
|
+
image1DArrayShadow image2DArrayShadow
|
83
|
+
imageBuffer iimageBuffer uimageBuffer
|
84
|
+
sizeof cast
|
85
|
+
namespace using
|
86
|
+
row_major
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.builtins
|
91
|
+
@builtins ||= Set.new %w(
|
92
|
+
gl_VertexID gl_InstanceID gl_PerVertex gl_Position gl_PointSize gl_ClipDistance
|
93
|
+
gl_PrimitiveIDIn gl_InvocationID gl_PrimitiveID gl_Layer gl_ViewportIndex
|
94
|
+
gl_MaxPatchVertices gl_PatchVerticesIn gl_TessLevelOuter gl_TessLevelInner
|
95
|
+
gl_TessCoord gl_FragCoord gl_FrontFacing gl_PointCoord gl_SampleID gl_SamplePosition
|
96
|
+
gl_FragColor gl_FragData gl_MaxDrawBuffers gl_FragDepth gl_SampleMask
|
97
|
+
gl_ClipVertex gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor
|
98
|
+
gl_TexCoord gl_FogFragCoord gl_Color gl_SecondaryColor gl_Normal gl_VertexID
|
99
|
+
gl_MultiTexCord0 gl_MultiTexCord1 gl_MultiTexCord2 gl_MultiTexCord3
|
100
|
+
gl_MultiTexCord4 gl_MultiTexCord5 gl_MultiTexCord6 gl_MultiTexCord7
|
101
|
+
gl_FogCoord gl_MaxVertexAttribs gl_MaxVertexUniformComponents
|
102
|
+
gl_MaxVaryingFloats gl_MaxVaryingComponents gl_MaxVertexOutputComponents
|
103
|
+
gl_MaxGeometryInputComponents gl_MaxGeometryOutputComponents
|
104
|
+
gl_MaxFragmentInputComponents gl_MaxVertexTextureImageUnits
|
105
|
+
gl_MaxCombinedTextureImageUnits gl_MaxTextureImageUnits
|
106
|
+
gl_MaxFragmentUniformComponents gl_MaxClipDistances
|
107
|
+
gl_MaxGeometryTextureImageUnits gl_MaxGeometryUniformComponents
|
108
|
+
gl_MaxGeometryVaryingComponents gl_MaxTessControlInputComponents
|
109
|
+
gl_MaxTessControlOutputComponents gl_MaxTessControlTextureImageUnits
|
110
|
+
gl_MaxTessControlUniformComponents gl_MaxTessControlTotalOutputComponents
|
111
|
+
gl_MaxTessEvaluationInputComponents gl_MaxTessEvaluationOutputComponents
|
112
|
+
gl_MaxTessEvaluationTextureImageUnits gl_MaxTessEvaluationUniformComponents
|
113
|
+
gl_MaxTessPatchComponents gl_MaxTessGenLevel gl_MaxViewports
|
114
|
+
gl_MaxVertexUniformVectors gl_MaxFragmentUniformVectors gl_MaxVaryingVectors
|
115
|
+
gl_MaxTextureUnits gl_MaxTextureCoords gl_MaxClipPlanes gl_DepthRange
|
116
|
+
gl_DepthRangeParameters gl_ModelViewMatrix gl_ProjectionMatrix
|
117
|
+
gl_ModelViewProjectionMatrix gl_TextureMatrix gl_NormalMatrix
|
118
|
+
gl_ModelViewMatrixInverse gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse
|
119
|
+
gl_TextureMatrixInverse gl_ModelViewMatrixTranspose
|
120
|
+
gl_ModelViewProjectionMatrixTranspose gl_TextureMatrixTranspose
|
121
|
+
gl_ModelViewMatrixInverseTranspose gl_ProjectionMatrixInverseTranspose
|
122
|
+
gl_ModelViewProjectionMatrixInverseTranspose
|
123
|
+
gl_TextureMatrixInverseTranspose gl_NormalScale gl_ClipPlane gl_PointParameters
|
124
|
+
gl_Point gl_MaterialParameters gl_FrontMaterial gl_BackMaterial
|
125
|
+
gl_LightSourceParameters gl_LightSource gl_MaxLights gl_LightModelParameters
|
126
|
+
gl_LightModel gl_LightModelProducts gl_FrontLightModelProduct
|
127
|
+
gl_BackLightModelProduct gl_LightProducts gl_FrontLightProduct
|
128
|
+
gl_BackLightProduct gl_TextureEnvColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR
|
129
|
+
gl_EyePlaneQ gl_ObjectPlaneS gl_ObjectPlaneT gl_ObjectPlaneR gl_ObjectPlaneQ
|
130
|
+
gl_FogParameters gl_Fog
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -84,7 +84,7 @@ module Rouge
|
|
84
84
|
@keywords ||= Set.new %w(
|
85
85
|
for in while do break return continue switch case default
|
86
86
|
if else throw try catch finally new delete typeof instanceof
|
87
|
-
void this
|
87
|
+
void this yield
|
88
88
|
)
|
89
89
|
end
|
90
90
|
|
@@ -206,7 +206,7 @@ module Rouge
|
|
206
206
|
desc "JavaScript Object Notation (json.org)"
|
207
207
|
tag 'json'
|
208
208
|
filenames '*.json'
|
209
|
-
mimetypes 'application/json'
|
209
|
+
mimetypes 'application/json', 'application/vnd.api+json'
|
210
210
|
|
211
211
|
# TODO: is this too much of a performance hit? JSON is quite simple,
|
212
212
|
# so I'd think this wouldn't be too bad, but for large documents this
|
@@ -215,14 +215,12 @@ module Rouge
|
|
215
215
|
return 0.8 if text =~ /\A\s*{/m && text.lexes_cleanly?(self)
|
216
216
|
end
|
217
217
|
|
218
|
+
string = /"(\\.|[^"])*"/
|
219
|
+
|
218
220
|
state :root do
|
219
221
|
mixin :whitespace
|
220
|
-
# special case for empty objects
|
221
|
-
rule /(\{)(\s*)(\})/m do
|
222
|
-
groups Punctuation, Text::Whitespace, Punctuation
|
223
|
-
end
|
224
222
|
rule /(?:true|false|null)\b/, Keyword::Constant
|
225
|
-
rule /{/, Punctuation, :
|
223
|
+
rule /{/, Punctuation, :object_key_initial
|
226
224
|
rule /\[/, Punctuation, :array
|
227
225
|
rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
|
228
226
|
rule /-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
|
@@ -234,12 +232,23 @@ module Rouge
|
|
234
232
|
end
|
235
233
|
|
236
234
|
state :has_string do
|
237
|
-
rule
|
235
|
+
rule string, Str::Double
|
236
|
+
end
|
237
|
+
|
238
|
+
# in object_key_initial it's allowed to immediately close the object again
|
239
|
+
state :object_key_initial do
|
240
|
+
mixin :whitespace
|
241
|
+
rule string do
|
242
|
+
token Name::Tag
|
243
|
+
goto :object_key
|
244
|
+
end
|
245
|
+
rule /}/, Punctuation, :pop!
|
238
246
|
end
|
239
247
|
|
248
|
+
# in object_key at least one more name/value pair is required
|
240
249
|
state :object_key do
|
241
250
|
mixin :whitespace
|
242
|
-
|
251
|
+
rule string, Name::Tag
|
243
252
|
rule /:/, Punctuation, :object_val
|
244
253
|
rule /}/, Error, :pop!
|
245
254
|
end
|
@@ -256,5 +265,33 @@ module Rouge
|
|
256
265
|
mixin :root
|
257
266
|
end
|
258
267
|
end
|
268
|
+
|
269
|
+
class JSONDOC < JSON
|
270
|
+
desc "JavaScript Object Notation with extenstions for documentation"
|
271
|
+
tag 'json-doc'
|
272
|
+
|
273
|
+
prepend :root do
|
274
|
+
mixin :comments
|
275
|
+
rule /(\.\.\.)/, Comment::Single
|
276
|
+
end
|
277
|
+
|
278
|
+
prepend :object_key_initial do
|
279
|
+
mixin :comments
|
280
|
+
rule /(\.\.\.)/, Comment::Single
|
281
|
+
end
|
282
|
+
|
283
|
+
prepend :object_key do
|
284
|
+
mixin :comments
|
285
|
+
rule /(\.\.\.)/ do
|
286
|
+
token Comment::Single
|
287
|
+
goto :object_key_initial
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
state :comments do
|
292
|
+
rule %r(//.*?$), Comment::Single
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
259
296
|
end
|
260
297
|
end
|
data/lib/rouge/lexers/liquid.rb
CHANGED
@@ -131,9 +131,7 @@ module Rouge
|
|
131
131
|
groups nil, Operator, Operator::Word
|
132
132
|
end
|
133
133
|
|
134
|
-
rule /(
|
135
|
-
groups nil, Text::Whitespace, Operator::Word, Text::Whitespace
|
136
|
-
end
|
134
|
+
rule /(contains)/, Operator::Word
|
137
135
|
|
138
136
|
mixin :generic
|
139
137
|
mixin :whitespace
|
@@ -168,6 +166,7 @@ module Rouge
|
|
168
166
|
# states for unknown markup
|
169
167
|
state :param_markup do
|
170
168
|
mixin :whitespace
|
169
|
+
mixin :string
|
171
170
|
|
172
171
|
rule /([^\s=:]+)(\s*)(=|:)/ do
|
173
172
|
groups Name::Attribute, Text::Whitespace, Operator
|
@@ -177,7 +176,6 @@ module Rouge
|
|
177
176
|
groups Punctuation, Text::Whitespace, nil, Text::Whitespace, Punctuation
|
178
177
|
end
|
179
178
|
|
180
|
-
mixin :string
|
181
179
|
mixin :number
|
182
180
|
mixin :keyword
|
183
181
|
|
@@ -196,12 +194,12 @@ module Rouge
|
|
196
194
|
end
|
197
195
|
|
198
196
|
state :tag_markup do
|
199
|
-
|
197
|
+
mixin :end_of_block
|
200
198
|
mixin :default_param_markup
|
201
199
|
end
|
202
200
|
|
203
201
|
state :variable_tag_markup do
|
204
|
-
|
202
|
+
mixin :end_of_block
|
205
203
|
mixin :variable_param_markup
|
206
204
|
end
|
207
205
|
|
@@ -225,7 +223,13 @@ module Rouge
|
|
225
223
|
rule /\d+/, Num::Integer
|
226
224
|
end
|
227
225
|
|
226
|
+
state :array_index do
|
227
|
+
rule /\[/, Punctuation
|
228
|
+
rule /\]/, Punctuation
|
229
|
+
end
|
230
|
+
|
228
231
|
state :generic do
|
232
|
+
mixin :array_index
|
229
233
|
mixin :keyword
|
230
234
|
mixin :string
|
231
235
|
mixin :variable
|
@@ -258,6 +262,7 @@ module Rouge
|
|
258
262
|
|
259
263
|
state :assign do
|
260
264
|
mixin :whitespace
|
265
|
+
mixin :end_of_block
|
261
266
|
|
262
267
|
rule /(\s*)(=)(\s*)/ do
|
263
268
|
groups Text::Whitespace, Operator, Text::Whitespace
|
@@ -79,6 +79,7 @@ module Rouge
|
|
79
79
|
|
80
80
|
rule /[?]/, Punctuation, :ternary
|
81
81
|
rule /\[/, Punctuation, :message
|
82
|
+
rule /@\[/, Punctuation, :array_literal
|
82
83
|
end
|
83
84
|
|
84
85
|
state :ternary do
|
@@ -115,6 +116,12 @@ module Rouge
|
|
115
116
|
mixin :message_shared
|
116
117
|
end
|
117
118
|
|
119
|
+
state :array_literal do
|
120
|
+
rule /]/, Punctuation, :pop!
|
121
|
+
rule /,/, Punctuation
|
122
|
+
mixin :statements
|
123
|
+
end
|
124
|
+
|
118
125
|
state :classname do
|
119
126
|
mixin :whitespace
|
120
127
|
|
data/lib/rouge/lexers/php.rb
CHANGED
@@ -56,7 +56,7 @@ module Rouge
|
|
56
56
|
while endforeach global __FILE__ endif list __LINE__ endswitch
|
57
57
|
new __sleep endwhile not array __wakeup E_ALL NULL final
|
58
58
|
php_user_filter interface implements public private protected
|
59
|
-
abstract clone try catch throw this use namespace
|
59
|
+
abstract clone try catch throw this use namespace yield
|
60
60
|
)
|
61
61
|
end
|
62
62
|
|
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -9,7 +9,7 @@ module Rouge
|
|
9
9
|
aliases 'rb'
|
10
10
|
filenames '*.rb', '*.ruby', '*.rbw', '*.rake', '*.gemspec', '*.podspec',
|
11
11
|
'Rakefile', 'Guardfile', 'Gemfile', 'Capfile', 'Podfile',
|
12
|
-
'Vagrantfile', '*.ru', '*.prawn'
|
12
|
+
'Vagrantfile', '*.ru', '*.prawn', 'Berksfile'
|
13
13
|
|
14
14
|
mimetypes 'text/x-ruby', 'application/x-ruby'
|
15
15
|
|
@@ -215,7 +215,7 @@ module Rouge
|
|
215
215
|
rule /[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
|
216
216
|
rule /(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
|
217
217
|
groups Punctuation, Text, Name::Function
|
218
|
-
push :
|
218
|
+
push :method_call
|
219
219
|
end
|
220
220
|
|
221
221
|
rule /[a-zA-Z_]\w*[?!]/, Name, :expr_start
|
@@ -8,12 +8,18 @@ module Rouge
|
|
8
8
|
|
9
9
|
state :content_common do
|
10
10
|
rule /@for\b/, Keyword, :for
|
11
|
-
rule /@(debug|warn|if|while)/, Keyword, :value
|
11
|
+
rule /@(debug|warn|if|each|while|else|return|media)/, Keyword, :value
|
12
|
+
|
12
13
|
rule /(@mixin)(\s+)(#{id})/ do
|
13
14
|
groups Keyword, Text, Name::Function
|
14
15
|
push :value
|
15
16
|
end
|
16
17
|
|
18
|
+
rule /(@function)(\s+)(#{id})/ do
|
19
|
+
groups Keyword, Text, Name::Function
|
20
|
+
push :value
|
21
|
+
end
|
22
|
+
|
17
23
|
rule /@extend\b/, Keyword, :selector
|
18
24
|
|
19
25
|
rule /(@include)(\s+)(#{id})/ do
|
data/lib/rouge/lexers/slim.rb
CHANGED
@@ -20,11 +20,6 @@ module Rouge
|
|
20
20
|
# Since you are allowed to wrap lines with a backslash, include \\\n in characters
|
21
21
|
dot = /(\\\n|.)/
|
22
22
|
|
23
|
-
def self.analyze_text(text)
|
24
|
-
return 1 if text.start_with? 'doctype'
|
25
|
-
return 1 if text =~ /(\*)(\{.+?\})/ # Contans a hash splat
|
26
|
-
end
|
27
|
-
|
28
23
|
def ruby
|
29
24
|
@ruby ||= Ruby.new(options)
|
30
25
|
end
|
@@ -46,6 +41,8 @@ module Rouge
|
|
46
41
|
}
|
47
42
|
end
|
48
43
|
|
44
|
+
start { ruby.reset!; html.reset! }
|
45
|
+
|
49
46
|
state :root do
|
50
47
|
rule /\s*\n/, Text
|
51
48
|
rule(/\s*/) { |m| token Text; indentation(m[0]) }
|
@@ -146,6 +143,9 @@ module Rouge
|
|
146
143
|
delegate ruby, m[2]
|
147
144
|
end
|
148
145
|
|
146
|
+
# HTML Entities
|
147
|
+
rule(/&\S*?;/, Name::Entity)
|
148
|
+
|
149
149
|
rule /#{dot}+?/, Text
|
150
150
|
|
151
151
|
rule /\s*\n/, Text::Whitespace, :pop!
|
@@ -158,7 +158,7 @@ module Rouge
|
|
158
158
|
|
159
159
|
state :html_attr do
|
160
160
|
# Strings, double/single quoted
|
161
|
-
rule
|
161
|
+
rule(/\s*(['"])#{dot}*?\1/, Literal::String, :pop!)
|
162
162
|
|
163
163
|
# Ruby stuff
|
164
164
|
rule(/(#{ruby_chars}+\(.*?\))/) { |m| delegate ruby, m[1]; pop! }
|
@@ -196,6 +196,9 @@ module Rouge
|
|
196
196
|
delegate html, m[1]
|
197
197
|
end
|
198
198
|
|
199
|
+
# HTML Entities
|
200
|
+
rule(/&\S*?;/, Name::Entity)
|
201
|
+
|
199
202
|
#rule /([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do
|
200
203
|
rule /#{dot}+?/, Text
|
201
204
|
|
data/lib/rouge/lexers/swift.rb
CHANGED
@@ -26,7 +26,7 @@ module Rouge
|
|
26
26
|
)
|
27
27
|
|
28
28
|
attributes = Set.new %w(
|
29
|
-
autoclosure IBAction IBDesignable IBInspectable IBOutlet noreturn NSCopying NSManaged objc UIApplicationMain NSApplicationMain objc_block
|
29
|
+
autoclosure IBAction IBDesignable IBInspectable IBOutlet noreturn NSCopying NSManaged objc UIApplicationMain NSApplicationMain objc_block noescape
|
30
30
|
)
|
31
31
|
|
32
32
|
constants = Set.new %w(
|
@@ -75,6 +75,8 @@ module Rouge
|
|
75
75
|
rule /(@objc[(])([^)]+)([)])/ do
|
76
76
|
groups Keyword::Declaration, Name::Class, Keyword::Declaration
|
77
77
|
end
|
78
|
+
|
79
|
+
rule /@autoclosure\(escaping\)/, Keyword::Declaration
|
78
80
|
|
79
81
|
rule /@(#{id})/ do |m|
|
80
82
|
if attributes.include? m[1]
|
@@ -111,6 +113,8 @@ module Rouge
|
|
111
113
|
token Name::Function
|
112
114
|
end
|
113
115
|
end
|
116
|
+
|
117
|
+
rule /as[?!]?/, Keyword
|
114
118
|
|
115
119
|
rule /(#?(?!default)(?![[:upper:]])#{id})(\s*)(:)/ do
|
116
120
|
groups Name::Variable, Text, Punctuation
|
data/lib/rouge/token.rb
CHANGED
@@ -74,7 +74,7 @@ module Rouge
|
|
74
74
|
# XXX IMPORTANT XXX
|
75
75
|
# For compatibility, this list must be kept in sync with
|
76
76
|
# pygments.token.STANDARD_TYPES
|
77
|
-
# please see https://github.com/
|
77
|
+
# please see https://github.com/jneen/rouge/wiki/List-of-tokens
|
78
78
|
token :Text, '' do
|
79
79
|
token :Whitespace, 'w'
|
80
80
|
end
|
data/lib/rouge/version.rb
CHANGED
data/rouge.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
Rouge aims to a be a simple, easy-to-extend drop-in replacement
|
11
11
|
for pygments.
|
12
12
|
desc
|
13
|
-
s.homepage = "http://
|
13
|
+
s.homepage = "http://rouge.jneen.net/"
|
14
14
|
s.rubyforge_project = "rouge"
|
15
15
|
s.files = Dir['Gemfile', 'LICENSE', 'rouge.gemspec', 'lib/**/*.rb', 'lib/**/*.yml', 'bin/rougify', 'lib/rouge/demos/*']
|
16
16
|
s.executables = %w(rougify)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeanine Adkisson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
|
14
14
|
email:
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/rouge/demos/erlang
|
41
41
|
- lib/rouge/demos/factor
|
42
42
|
- lib/rouge/demos/gherkin
|
43
|
+
- lib/rouge/demos/glsl
|
43
44
|
- lib/rouge/demos/go
|
44
45
|
- lib/rouge/demos/groovy
|
45
46
|
- lib/rouge/demos/haml
|
@@ -52,6 +53,7 @@ files:
|
|
52
53
|
- lib/rouge/demos/java
|
53
54
|
- lib/rouge/demos/javascript
|
54
55
|
- lib/rouge/demos/json
|
56
|
+
- lib/rouge/demos/json-doc
|
55
57
|
- lib/rouge/demos/liquid
|
56
58
|
- lib/rouge/demos/literate_coffeescript
|
57
59
|
- lib/rouge/demos/literate_haskell
|
@@ -119,6 +121,7 @@ files:
|
|
119
121
|
- lib/rouge/lexers/factor.rb
|
120
122
|
- lib/rouge/lexers/gherkin.rb
|
121
123
|
- lib/rouge/lexers/gherkin/keywords.rb
|
124
|
+
- lib/rouge/lexers/glsl.rb
|
122
125
|
- lib/rouge/lexers/go.rb
|
123
126
|
- lib/rouge/lexers/groovy.rb
|
124
127
|
- lib/rouge/lexers/haml.rb
|
@@ -194,7 +197,7 @@ files:
|
|
194
197
|
- lib/rouge/util.rb
|
195
198
|
- lib/rouge/version.rb
|
196
199
|
- rouge.gemspec
|
197
|
-
homepage: http://
|
200
|
+
homepage: http://rouge.jneen.net/
|
198
201
|
licenses:
|
199
202
|
- MIT (see LICENSE file)
|
200
203
|
metadata: {}
|