rouge 3.19.0 → 3.20.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/demos/augeas +16 -0
- data/lib/rouge/demos/bibtex +12 -0
- data/lib/rouge/demos/hlsl +20 -0
- data/lib/rouge/demos/livescript +15 -0
- data/lib/rouge/demos/velocity +9 -0
- data/lib/rouge/demos/zig +6 -0
- data/lib/rouge/lexers/augeas.rb +93 -0
- data/lib/rouge/lexers/bibtex.rb +115 -0
- data/lib/rouge/lexers/cpp.rb +6 -0
- data/lib/rouge/lexers/diff.rb +1 -1
- data/lib/rouge/lexers/haskell.rb +27 -19
- data/lib/rouge/lexers/hlsl.rb +166 -0
- data/lib/rouge/lexers/html.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +0 -2
- data/lib/rouge/lexers/jsx.rb +47 -59
- data/lib/rouge/lexers/livescript.rb +310 -0
- data/lib/rouge/lexers/opentype_feature_file.rb +27 -42
- data/lib/rouge/lexers/powershell.rb +3 -3
- data/lib/rouge/lexers/tsx.rb +10 -3
- data/lib/rouge/lexers/typescript.rb +1 -12
- data/lib/rouge/lexers/typescript/common.rb +18 -4
- data/lib/rouge/lexers/velocity.rb +71 -0
- data/lib/rouge/lexers/zig.rb +139 -0
- data/lib/rouge/version.rb +1 -1
- metadata +14 -2
@@ -12,24 +12,30 @@ module Rouge
|
|
12
12
|
|
13
13
|
def self.keywords
|
14
14
|
@keywords ||= %w(
|
15
|
-
Ascender Attach CapHeight CaretOffset CodePageRange
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
Ascender Attach AxisValue CapHeight CaretOffset CodePageRange
|
16
|
+
DesignAxis Descender ElidedFallbackName ElidedFallbackNameID
|
17
|
+
ElidableAxisValueName FeatUILabelNameID FeatUITooltipTextNameID
|
18
|
+
FontRevision FSType GlyphClassDef HorizAxis.BaseScriptList
|
19
|
+
HorizAxis.BaseTagList HorizAxis.MinMax IgnoreBaseGlyphs
|
20
|
+
IgnoreLigatures IgnoreMarks LigatureCaretByDev LigatureCaretByIndex
|
21
|
+
LigatureCaretByPos LineGap MarkAttachClass MarkAttachmentType NULL
|
22
|
+
OlderSiblingFontAttribute Panose ParamUILabelNameID RightToLeft
|
23
|
+
SampleTextNameID TypoAscender TypoDescender TypoLineGap UnicodeRange
|
24
|
+
UseMarkFilteringSet Vendor VertAdvanceY VertAxis.BaseScriptList
|
25
|
+
VertAxis.BaseTagList VertAxis.MinMax VertOriginY VertTypoAscender
|
26
|
+
VertTypoDescender VertTypoLineGap WeightClass WidthClass XHeight
|
27
|
+
|
28
|
+
anchorDef anchor anonymous anon by contour cursive device enumerate
|
29
|
+
enum exclude_dflt featureNames feature flag from ignore include_dflt
|
30
|
+
include languagesystem language location lookupflag lookup markClass
|
31
|
+
mark nameid name parameters position pos required reversesub rsub
|
32
|
+
script sizemenuname substitute subtable sub table useExtension
|
27
33
|
valueRecordDef winAscent winDescent
|
28
34
|
)
|
29
35
|
end
|
30
36
|
|
31
37
|
|
32
|
-
identifier = %r/[a-z_][a-z0-9\/_]*/i
|
38
|
+
identifier = %r/[a-z_][a-z0-9\/_.-]*/i
|
33
39
|
|
34
40
|
state :root do
|
35
41
|
rule %r/\s+/m, Text::Whitespace
|
@@ -41,17 +47,18 @@ module Rouge
|
|
41
47
|
push :featurename
|
42
48
|
end
|
43
49
|
# } <tag> ;
|
44
|
-
rule %r/(\})((?:\s)
|
50
|
+
rule %r/(\})((?:\s))/ do
|
45
51
|
groups Punctuation, Text
|
46
52
|
push :featurename
|
47
53
|
end
|
48
54
|
# solve include( ../path)
|
49
|
-
rule %r/
|
55
|
+
rule %r/include\b/i, Keyword, :includepath
|
50
56
|
|
51
57
|
rule %r/[\-\[\]\/(){},.:;=%*<>']/, Punctuation
|
52
58
|
|
53
59
|
rule %r/`.*?/, Str::Backtick
|
54
|
-
rule %r/\"/, Str, :
|
60
|
+
rule %r/\"/, Str, :strings
|
61
|
+
rule %r/\\[^.*\s]+/i, Str::Escape
|
55
62
|
|
56
63
|
# classes, start with @<nameOfClass>
|
57
64
|
rule %r/@#{identifier}/, Name::Class
|
@@ -66,6 +73,7 @@ module Rouge
|
|
66
73
|
end
|
67
74
|
|
68
75
|
rule identifier, Name
|
76
|
+
rule %r/(?:0x|\\)[0-9A-Fa-f]+/, Num::Hex
|
69
77
|
rule %r/-?\d+/, Num::Integer
|
70
78
|
end
|
71
79
|
|
@@ -77,37 +85,14 @@ module Rouge
|
|
77
85
|
rule %r/\s+/, Text::Whitespace
|
78
86
|
rule %r/\)/, Punctuation, :pop!
|
79
87
|
rule %r/\(/, Punctuation
|
80
|
-
rule %r/[
|
88
|
+
rule %r/[^\s()]+/, Str
|
81
89
|
end
|
82
90
|
|
83
91
|
state :strings do
|
84
|
-
rule %r/(\([a-z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/i, Str
|
85
|
-
end
|
86
|
-
|
87
|
-
state :strings_double do
|
88
|
-
rule %r/[^\\"%\n]+/, Str
|
89
|
-
mixin :strings
|
90
|
-
end
|
91
|
-
|
92
|
-
state :escape do
|
93
|
-
rule %r(\\
|
94
|
-
( [\\abfnrtv"']
|
95
|
-
| \n
|
96
|
-
| N{[a-zA-z][a-zA-Z ]+[a-zA-Z]}
|
97
|
-
| u[a-fA-F0-9]{4}
|
98
|
-
| U[a-fA-F0-9]{8}
|
99
|
-
| x[a-fA-F0-9]{2}
|
100
|
-
| [0-7]{1,3}
|
101
|
-
)
|
102
|
-
)x, Str::Escape
|
103
|
-
end
|
104
|
-
|
105
|
-
state :dqs do
|
106
92
|
rule %r/"/, Str, :pop!
|
107
|
-
|
108
|
-
|
93
|
+
rule %r/[^"%\n]+/, Str
|
94
|
+
rule %r/(\([a-z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/i, Str
|
109
95
|
end
|
110
|
-
|
111
96
|
end
|
112
97
|
end
|
113
98
|
end
|
@@ -201,7 +201,7 @@ module Rouge
|
|
201
201
|
rule %r/(?:#{KEYWORDS})\b(?![-.])/i, Keyword::Reserved
|
202
202
|
|
203
203
|
rule %r/-{1,2}\w+/, Name::Tag
|
204
|
-
|
204
|
+
|
205
205
|
rule %r/(\.)?([-\w]+)(\[)/ do |m|
|
206
206
|
groups Operator, Name::Function, Punctuation
|
207
207
|
push :bracket
|
@@ -209,12 +209,12 @@ module Rouge
|
|
209
209
|
|
210
210
|
rule %r/([\/\\~\w][-.:\/\\~\w]*)(\n)?/ do |m|
|
211
211
|
groups Name::Function, Text::Whitespace
|
212
|
-
push :parameters
|
212
|
+
push :parameters
|
213
213
|
end
|
214
214
|
|
215
215
|
rule %r/(\.)?([-\w]+)(?:(\()|(\n))?/ do |m|
|
216
216
|
groups Operator, Name::Function, Punctuation, Text::Whitespace
|
217
|
-
push :parameters unless m[3]
|
217
|
+
push :parameters unless m[3].nil?
|
218
218
|
end
|
219
219
|
|
220
220
|
rule %r/[-+*\/%=!.&|]/, Operator
|
data/lib/rouge/lexers/tsx.rb
CHANGED
@@ -7,13 +7,20 @@ module Rouge
|
|
7
7
|
load_lexer 'typescript/common.rb'
|
8
8
|
|
9
9
|
class TSX < JSX
|
10
|
-
|
10
|
+
extend TypescriptCommon
|
11
11
|
|
12
|
-
title '
|
13
|
-
desc '
|
12
|
+
title 'TSX'
|
13
|
+
desc 'TypeScript-compatible JSX (www.typescriptlang.org/docs/handbook/jsx.html)'
|
14
14
|
|
15
15
|
tag 'tsx'
|
16
16
|
filenames '*.tsx'
|
17
|
+
|
18
|
+
prepend :element_name do
|
19
|
+
rule %r/(\w+)(,)/ do
|
20
|
+
groups Name::Other, Punctuation
|
21
|
+
pop! 3
|
22
|
+
end
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
@@ -7,7 +7,7 @@ module Rouge
|
|
7
7
|
load_lexer 'typescript/common.rb'
|
8
8
|
|
9
9
|
class Typescript < Javascript
|
10
|
-
|
10
|
+
extend TypescriptCommon
|
11
11
|
|
12
12
|
title "TypeScript"
|
13
13
|
desc "TypeScript, a superset of JavaScript"
|
@@ -18,17 +18,6 @@ module Rouge
|
|
18
18
|
filenames '*.ts', '*.d.ts'
|
19
19
|
|
20
20
|
mimetypes 'text/typescript'
|
21
|
-
|
22
|
-
prepend :root do
|
23
|
-
rule %r/[?][.]/, Punctuation
|
24
|
-
end
|
25
|
-
|
26
|
-
prepend :statement do
|
27
|
-
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
|
28
|
-
groups Name::Label, Punctuation, Text, Punctuation
|
29
|
-
push :expr_start
|
30
|
-
end
|
31
|
-
end
|
32
21
|
end
|
33
22
|
end
|
34
23
|
end
|
@@ -4,31 +4,45 @@
|
|
4
4
|
module Rouge
|
5
5
|
module Lexers
|
6
6
|
module TypescriptCommon
|
7
|
-
def
|
7
|
+
def keywords
|
8
8
|
@keywords ||= super + Set.new(%w(
|
9
9
|
is namespace static private protected public
|
10
10
|
implements readonly
|
11
11
|
))
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def declarations
|
15
15
|
@declarations ||= super + Set.new(%w(
|
16
16
|
type abstract
|
17
17
|
))
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def reserved
|
21
21
|
@reserved ||= super + Set.new(%w(
|
22
22
|
string any void number namespace module
|
23
23
|
declare default interface keyof
|
24
24
|
))
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def builtins
|
28
28
|
@builtins ||= super + %w(
|
29
29
|
Pick Partial Readonly Record
|
30
30
|
)
|
31
31
|
end
|
32
|
+
|
33
|
+
def self.extended(base)
|
34
|
+
base.prepend :root do
|
35
|
+
rule %r/[?][.]/, base::Punctuation
|
36
|
+
rule %r/[?]{2}/, base::Operator
|
37
|
+
end
|
38
|
+
|
39
|
+
base.prepend :statement do
|
40
|
+
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
|
41
|
+
groups base::Name::Label, base::Punctuation, base::Text, base::Punctuation
|
42
|
+
push :expr_start
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
32
46
|
end
|
33
47
|
end
|
34
48
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Velocity < TemplateLexer
|
6
|
+
title 'Velocity'
|
7
|
+
desc 'Velocity is a Java-based template engine (velocity.apache.org)'
|
8
|
+
tag 'velocity'
|
9
|
+
filenames '*.vm', '*.velocity', '*.fhtml'
|
10
|
+
mimetypes 'text/html+velocity'
|
11
|
+
|
12
|
+
id = /[a-z_]\w*/i
|
13
|
+
|
14
|
+
state :root do
|
15
|
+
rule %r/[^{#$]+/ do
|
16
|
+
delegate parent
|
17
|
+
end
|
18
|
+
|
19
|
+
rule %r/(#)(\*.*?\*)(#)/m, Comment::Multiline
|
20
|
+
rule %r/(##)(.*?$)/, Comment::Single
|
21
|
+
|
22
|
+
rule %r/(#\{?)(#{id})(\}?)(\s?\()/m do
|
23
|
+
groups Punctuation, Name::Function, Punctuation, Punctuation
|
24
|
+
push :directive_params
|
25
|
+
end
|
26
|
+
|
27
|
+
rule %r/(#\{?)(#{id})(\}|\b)/m do
|
28
|
+
groups Punctuation, Name::Function, Punctuation
|
29
|
+
end
|
30
|
+
|
31
|
+
rule %r/\$\{?/, Punctuation, :variable
|
32
|
+
end
|
33
|
+
|
34
|
+
state :variable do
|
35
|
+
rule %r/#{id}/, Name::Variable
|
36
|
+
rule %r/\(/, Punctuation, :func_params
|
37
|
+
rule %r/(\.)(#{id})/ do
|
38
|
+
groups Punctuation, Name::Variable
|
39
|
+
end
|
40
|
+
rule %r/\}/, Punctuation, :pop!
|
41
|
+
rule(//) { pop! }
|
42
|
+
end
|
43
|
+
|
44
|
+
state :directive_params do
|
45
|
+
rule %r/(&&|\|\||==?|!=?|[-<>+*%&|^\/])|\b(eq|ne|gt|lt|ge|le|not|in)\b/, Operator
|
46
|
+
rule %r/\[/, Operator, :range_operator
|
47
|
+
rule %r/\b#{id}\b/, Name::Function
|
48
|
+
mixin :func_params
|
49
|
+
end
|
50
|
+
|
51
|
+
state :range_operator do
|
52
|
+
rule %r/[.]{2}/, Operator
|
53
|
+
mixin :func_params
|
54
|
+
rule %r/\]/, Operator, :pop!
|
55
|
+
end
|
56
|
+
|
57
|
+
state :func_params do
|
58
|
+
rule %r/\$\{?/, Punctuation, :variable
|
59
|
+
rule %r/\s+/, Text
|
60
|
+
rule %r/,/, Punctuation
|
61
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Str::Double
|
62
|
+
rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
|
63
|
+
rule %r/0[xX][0-9a-fA-F]+[Ll]?/, Num::Hex
|
64
|
+
rule %r/\b[0-9]+\b/, Num::Integer
|
65
|
+
rule %r/(true|false|null)\b/, Keyword::Constant
|
66
|
+
rule %r/[(\[]/, Punctuation, :push!
|
67
|
+
rule %r/[)\]}]/, Punctuation, :pop!
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Zig < RegexLexer
|
7
|
+
tag 'zig'
|
8
|
+
aliases 'zir'
|
9
|
+
filenames '*.zig'
|
10
|
+
mimetypes 'text/x-zig'
|
11
|
+
|
12
|
+
title 'Zig'
|
13
|
+
desc 'The Zig programming language (ziglang.org)'
|
14
|
+
|
15
|
+
def self.keywords
|
16
|
+
@keywords ||= %w(
|
17
|
+
align linksection threadlocal struct enum union error break return
|
18
|
+
anyframe fn c_longlong c_ulonglong c_longdouble c_void comptime_float
|
19
|
+
c_short c_ushort c_int c_uint c_long c_ulong continue asm defer
|
20
|
+
errdefer const var extern packed export pub if else switch and or
|
21
|
+
orelse while for bool unreachable try catch async suspend nosuspend
|
22
|
+
await resume undefined usingnamespace test void noreturn type
|
23
|
+
anyerror usize noalias inline noinline comptime callconv volatile
|
24
|
+
allowzero
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.builtins
|
29
|
+
@builtins ||= %w(
|
30
|
+
@addWithOverflow @as @atomicLoad @atomicStore @bitCast @breakpoint
|
31
|
+
@alignCast @alignOf @cDefine @cImport @cInclude @bitOffsetOf
|
32
|
+
@atomicRmw @bytesToSlice @byteOffsetOf @OpaqueType @panic @ptrCast
|
33
|
+
@bitReverse @Vector @sin @cUndef @canImplicitCast @clz @cmpxchgWeak
|
34
|
+
@cmpxchgStrong @compileError @compileLog @ctz @popCount @divExact
|
35
|
+
@divFloor @cos @divTrunc @embedFile @export @tagName @TagType
|
36
|
+
@errorName @call @errorReturnTrace @fence @fieldParentPtr @field
|
37
|
+
@unionInit @errorToInt @intToEnum @enumToInt @setAlignStack @frame
|
38
|
+
@Frame @exp @exp2 @log @log2 @log10 @fabs @floor @ceil @trunc @round
|
39
|
+
@floatCast @intToFloat @floatToInt @boolToInt @errSetCast @intToError
|
40
|
+
@frameAddress @import @newStackCall @asyncCall @intToPtr @intCast
|
41
|
+
@frameSize @memcpy @memset @mod @mulWithOverflow @splat @ptrToInt
|
42
|
+
@rem @returnAddress @setCold @Type @shuffle @setGlobalLinkage
|
43
|
+
@setGlobalSection @shlExact @This @hasDecl @hasField
|
44
|
+
@setRuntimeSafety @setEvalBranchQuota @setFloatMode @shlWithOverflow
|
45
|
+
@shrExact @sizeOf @bitSizeOf @sqrt @byteSwap @subWithOverflow
|
46
|
+
@sliceToBytes comptime_int @truncate @typeInfo @typeName @TypeOf
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
id = /[a-z_]\w*/i
|
51
|
+
escapes = /\\ ([nrt'"\\0] | x\h{2} | u\h{4} | U\h{8})/x
|
52
|
+
|
53
|
+
state :bol do
|
54
|
+
mixin :whitespace
|
55
|
+
rule %r/#\s[^\n]*/, Comment::Special
|
56
|
+
rule(//) { pop! }
|
57
|
+
end
|
58
|
+
|
59
|
+
state :attribute do
|
60
|
+
mixin :whitespace
|
61
|
+
mixin :literals
|
62
|
+
rule %r/[(,)=:]/, Name::Decorator
|
63
|
+
rule %r/\]/, Name::Decorator, :pop!
|
64
|
+
rule id, Name::Decorator
|
65
|
+
end
|
66
|
+
|
67
|
+
state :whitespace do
|
68
|
+
rule %r/\s+/, Text
|
69
|
+
rule %r(//[^\n]*), Comment
|
70
|
+
end
|
71
|
+
|
72
|
+
state :root do
|
73
|
+
rule %r/\n/, Text, :bol
|
74
|
+
|
75
|
+
mixin :whitespace
|
76
|
+
|
77
|
+
rule %r/\b(?:(i|u)[0-9]+)\b/, Keyword::Type
|
78
|
+
rule %r/\b(?:f(16|32|64|128))\b/, Keyword::Type
|
79
|
+
rule %r/\b(?:(isize|usize))\b/, Keyword::Type
|
80
|
+
|
81
|
+
mixin :literals
|
82
|
+
|
83
|
+
rule %r/'#{id}/, Name::Variable
|
84
|
+
rule %r/([.]?)(\s*)(@?#{id})(\s*)([(]?)/ do |m|
|
85
|
+
name = m[3]
|
86
|
+
t = if self.class.keywords.include? name
|
87
|
+
Keyword
|
88
|
+
elsif self.class.builtins.include? name
|
89
|
+
Name::Builtin
|
90
|
+
elsif !m[1].empty? && !m[5].empty?
|
91
|
+
Name::Function
|
92
|
+
elsif !m[1].empty?
|
93
|
+
Name::Property
|
94
|
+
else
|
95
|
+
Name
|
96
|
+
end
|
97
|
+
|
98
|
+
groups Punctuation, Text, t, Text, Punctuation
|
99
|
+
end
|
100
|
+
|
101
|
+
rule %r/[()\[\]{}|,:;]/, Punctuation
|
102
|
+
rule %r/[*\/!@~&+%^<>=\?-]|\.{1,3}/, Operator
|
103
|
+
end
|
104
|
+
|
105
|
+
state :literals do
|
106
|
+
rule %r/\b(?:true|false|null)\b/, Keyword::Constant
|
107
|
+
rule %r(
|
108
|
+
' (?: #{escapes} | [^\\] ) '
|
109
|
+
)x, Str::Char
|
110
|
+
|
111
|
+
rule %r/"/, Str, :string
|
112
|
+
rule %r/r(#*)".*?"\1/m, Str
|
113
|
+
|
114
|
+
dot = /[.][0-9_]+/
|
115
|
+
exp = /e[-+]?[0-9_]+/
|
116
|
+
|
117
|
+
rule %r(
|
118
|
+
[0-9]+
|
119
|
+
(#{dot} #{exp}?
|
120
|
+
|#{dot}? #{exp}
|
121
|
+
)
|
122
|
+
)x, Num::Float
|
123
|
+
|
124
|
+
rule %r(
|
125
|
+
( 0b[10_]+
|
126
|
+
| 0x[0-9a-fA-F_]+
|
127
|
+
| [0-9_]+
|
128
|
+
)
|
129
|
+
)x, Num::Integer
|
130
|
+
end
|
131
|
+
|
132
|
+
state :string do
|
133
|
+
rule %r/"/, Str, :pop!
|
134
|
+
rule escapes, Str::Escape
|
135
|
+
rule %r/[^"\\]+/m, Str
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|