rouge 3.15.0 → 3.16.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 +1 -0
- data/lib/rouge/cli.rb +18 -1
- data/lib/rouge/demos/nasm +6 -6
- data/lib/rouge/demos/varnish +55 -0
- data/lib/rouge/formatters/terminal256.rb +22 -6
- data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
- data/lib/rouge/lexer.rb +2 -1
- data/lib/rouge/lexers/d.rb +3 -3
- data/lib/rouge/lexers/java.rb +4 -5
- data/lib/rouge/lexers/lua.rb +39 -1
- data/lib/rouge/lexers/objective_c/common.rb +2 -2
- data/lib/rouge/lexers/powershell.rb +5 -0
- data/lib/rouge/lexers/rust.rb +2 -10
- data/lib/rouge/lexers/shell.rb +1 -1
- data/lib/rouge/lexers/toml.rb +23 -0
- data/lib/rouge/lexers/typescript.rb +7 -0
- data/lib/rouge/lexers/varnish.rb +131 -0
- data/lib/rouge/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5342709cd08d6095557fbe22c79544c6be522f2343ed53360ab57f96bb37c077
|
4
|
+
data.tar.gz: 25e1d81909ad22cece899eaf4d6c32ec1e0931611031f3ac8a37b6be3bceb497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1244771613b6d0ec7523c834084974c4c9e6145a06d237e1bf937ffced73af0a7f7c4bf5efbf397b5bf943df7a66d4614cc601c82721f6b2d03425dc9118ecc
|
7
|
+
data.tar.gz: ba9ecdc95aae8f45745820720b167ac102c1ac6d9af431024090cb79dd7805fb2ba981207de97c052339388b2886d2eb79e036b9aa60aaa8b6bc869bef9b5468
|
data/lib/rouge.rb
CHANGED
@@ -72,6 +72,7 @@ load_relative 'rouge/formatters/html_linewise'
|
|
72
72
|
load_relative 'rouge/formatters/html_line_table'
|
73
73
|
load_relative 'rouge/formatters/html_inline'
|
74
74
|
load_relative 'rouge/formatters/terminal256'
|
75
|
+
load_relative 'rouge/formatters/terminal_truecolor'
|
75
76
|
load_relative 'rouge/formatters/tex'
|
76
77
|
load_relative 'rouge/formatters/null'
|
77
78
|
|
data/lib/rouge/cli.rb
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
# not required by the main lib.
|
5
5
|
# to use this module, require 'rouge/cli'.
|
6
6
|
|
7
|
+
require 'rbconfig'
|
8
|
+
|
7
9
|
module Rouge
|
8
10
|
class FileReader
|
9
11
|
attr_reader :input
|
@@ -200,9 +202,22 @@ module Rouge
|
|
200
202
|
yield %[ delimiters. implies --escape]
|
201
203
|
end
|
202
204
|
|
205
|
+
# There is no consistent way to do this, but this is used elsewhere,
|
206
|
+
# and we provide explicit opt-in and opt-out with $COLORTERM
|
207
|
+
def self.supports_truecolor?
|
208
|
+
return true if %w(24bit truecolor).include?(ENV['COLORTERM'])
|
209
|
+
return false if ENV['COLORTERM'] && ENV['COLORTERM'] =~ /256/
|
210
|
+
|
211
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
212
|
+
ENV['ConEmuANSI'] == 'ON' && !ENV['ANSICON']
|
213
|
+
else
|
214
|
+
ENV['TERM'] !~ /(^rxvt)|(-color$)/
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
203
218
|
def self.parse(argv)
|
204
219
|
opts = {
|
205
|
-
:formatter => 'terminal256',
|
220
|
+
:formatter => supports_truecolor? ? 'terminal-truecolor' : 'terminal256',
|
206
221
|
:theme => 'thankful_eyes',
|
207
222
|
:css_class => 'codehilite',
|
208
223
|
:input_file => '-',
|
@@ -299,8 +314,10 @@ module Rouge
|
|
299
314
|
|
300
315
|
theme = Theme.find(opts[:theme]).new or error! "unknown theme #{opts[:theme]}"
|
301
316
|
|
317
|
+
# TODO: document this in --help
|
302
318
|
@formatter = case opts[:formatter]
|
303
319
|
when 'terminal256' then Formatters::Terminal256.new(theme)
|
320
|
+
when 'terminal-truecolor' then Formatters::TerminalTruecolor.new(theme)
|
304
321
|
when 'html' then Formatters::HTML.new
|
305
322
|
when 'html-pygments' then Formatters::HTMLPygments.new(Formatters::HTML.new, opts[:css_class])
|
306
323
|
when 'html-inline' then Formatters::HTMLInline.new(theme)
|
data/lib/rouge/demos/nasm
CHANGED
@@ -10,12 +10,12 @@
|
|
10
10
|
extern irq_handler
|
11
11
|
|
12
12
|
irq_common_stub:
|
13
|
-
pusha
|
14
|
-
mov
|
15
|
-
push
|
16
|
-
mov
|
17
|
-
mov
|
18
|
-
call
|
13
|
+
pusha ; push all general-purpose registers
|
14
|
+
mov ax, ds ; lower 16-bits of eax = ds
|
15
|
+
push eax ; save the data segment descriptor
|
16
|
+
mov ax, 0x10 ; load the kernel data segment descriptor
|
17
|
+
mov edx, eax
|
18
|
+
call irq_handler
|
19
19
|
|
20
20
|
%assign i 0
|
21
21
|
%rep 8
|
@@ -0,0 +1,55 @@
|
|
1
|
+
vcl 4.0;
|
2
|
+
|
3
|
+
backend server1 {
|
4
|
+
.host = "server1.example.com";
|
5
|
+
.probe = {
|
6
|
+
.url = "/";
|
7
|
+
.timeout = 1s;
|
8
|
+
.interval = 5s;
|
9
|
+
.window = 5;
|
10
|
+
.threshold = 3;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
sub vcl_hit {
|
15
|
+
# Called when a cache lookup is successful.
|
16
|
+
|
17
|
+
if (obj.ttl >= 0s) {
|
18
|
+
# A pure unadultered hit, deliver it
|
19
|
+
return (deliver);
|
20
|
+
}
|
21
|
+
|
22
|
+
# https://www.varnish-cache.org/docs/trunk/users-guide/vcl-grace.html
|
23
|
+
# When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.
|
24
|
+
# If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.
|
25
|
+
|
26
|
+
# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {
|
27
|
+
# return (deliver);
|
28
|
+
# } else {
|
29
|
+
# return (fetch);
|
30
|
+
# }
|
31
|
+
|
32
|
+
# We have no fresh fish. Lets look at the stale ones.
|
33
|
+
if (std.healthy(req.backend_hint)) {
|
34
|
+
# Backend is healthy. Limit age to 10s.
|
35
|
+
if (obj.ttl + 10s > 0s) {
|
36
|
+
#set req.http.grace = "normal(limited)";
|
37
|
+
return (deliver);
|
38
|
+
} else {
|
39
|
+
# No candidate for grace. Fetch a fresh object.
|
40
|
+
return(fetch);
|
41
|
+
}
|
42
|
+
} else {
|
43
|
+
# backend is sick - use full grace
|
44
|
+
if (obj.ttl + obj.grace > 0s) {
|
45
|
+
#set req.http.grace = "full";
|
46
|
+
return (deliver);
|
47
|
+
} else {
|
48
|
+
# no graced object.
|
49
|
+
return (fetch);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
# fetch & deliver once we get the result
|
54
|
+
return (fetch); # Dead code, keep as a safeguard
|
55
|
+
}
|
@@ -24,10 +24,7 @@ module Rouge
|
|
24
24
|
|
25
25
|
def stream(tokens, &b)
|
26
26
|
tokens.each do |tok, val|
|
27
|
-
|
28
|
-
yield escape.style_string
|
29
|
-
yield val.gsub("\n", "#{escape.reset_string}\n#{escape.style_string}")
|
30
|
-
yield escape.reset_string
|
27
|
+
escape_sequence(tok).stream_value(val, &b)
|
31
28
|
end
|
32
29
|
end
|
33
30
|
|
@@ -85,6 +82,14 @@ module Rouge
|
|
85
82
|
@bg = style.bg && self.class.color_index(style.bg)
|
86
83
|
end
|
87
84
|
|
85
|
+
|
86
|
+
def stream_value(val, &b)
|
87
|
+
yield style_string
|
88
|
+
yield val.gsub("\e", "\\e")
|
89
|
+
.gsub("\n", "#{reset_string}\n#{style_string}")
|
90
|
+
yield reset_string
|
91
|
+
end
|
92
|
+
|
88
93
|
def style_string
|
89
94
|
@style_string ||= begin
|
90
95
|
attrs = []
|
@@ -157,12 +162,23 @@ module Rouge
|
|
157
162
|
end
|
158
163
|
end
|
159
164
|
|
165
|
+
class Unescape < EscapeSequence
|
166
|
+
def initialize(*) end
|
167
|
+
def style_string(*) '' end
|
168
|
+
def reset_string(*) '' end
|
169
|
+
def stream_value(val) yield val end
|
170
|
+
end
|
171
|
+
|
160
172
|
# private
|
161
173
|
def escape_sequence(token)
|
162
|
-
return
|
174
|
+
return Unescape.new if escape?(token)
|
163
175
|
@escape_sequences ||= {}
|
164
176
|
@escape_sequences[token.qualname] ||=
|
165
|
-
|
177
|
+
make_escape_sequence(get_style(token))
|
178
|
+
end
|
179
|
+
|
180
|
+
def make_escape_sequence(style)
|
181
|
+
EscapeSequence.new(style)
|
166
182
|
end
|
167
183
|
|
168
184
|
def get_style(token)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
module Rouge
|
4
|
+
module Formatters
|
5
|
+
class TerminalTruecolor < Terminal256
|
6
|
+
tag 'terminal_truecolor'
|
7
|
+
|
8
|
+
class TruecolorEscapeSequence < Terminal256::EscapeSequence
|
9
|
+
def style_string
|
10
|
+
@style_string ||= begin
|
11
|
+
out = String.new('')
|
12
|
+
out << escape(['48', '2', *get_rgb(style.bg)]) if style.bg
|
13
|
+
out << escape(['38', '2', *get_rgb(style.fg)]) if style.fg
|
14
|
+
out << escape(['1']) if style[:bold] || style[:italic]
|
15
|
+
out
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_rgb(color)
|
20
|
+
color = $1 if color =~ /#(\h+)/
|
21
|
+
|
22
|
+
case color.size
|
23
|
+
when 3 then color.chars.map { |c| c.to_i(16) * 2 }
|
24
|
+
when 6 then color.scan(/../).map { |cc| cc.to_i(16) }
|
25
|
+
else
|
26
|
+
raise "invalid color: #{color.inspect}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# @override
|
32
|
+
def make_escape_sequence(style)
|
33
|
+
TruecolorEscapeSequence.new(style)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rouge/lexer.rb
CHANGED
@@ -209,7 +209,8 @@ module Rouge
|
|
209
209
|
# Determine if a lexer has a method named +:detect?+ defined in its
|
210
210
|
# singleton class.
|
211
211
|
def detectable?
|
212
|
-
@detectable
|
212
|
+
return @detectable if defined?(@detectable)
|
213
|
+
@detectable = singleton_methods(false).include?(:detect?)
|
213
214
|
end
|
214
215
|
|
215
216
|
protected
|
data/lib/rouge/lexers/d.rb
CHANGED
@@ -35,9 +35,9 @@ module Rouge
|
|
35
35
|
)
|
36
36
|
|
37
37
|
keywords_pseudo = %w(
|
38
|
-
__FILE__ __MODULE__ __LINE__ __FUNCTION__
|
39
|
-
|
40
|
-
__VERSION__
|
38
|
+
__FILE__ __FILE_FULL_PATH__ __MODULE__ __LINE__ __FUNCTION__
|
39
|
+
__PRETTY_FUNCTION__ __DATE__ __EOF__ __TIME__ __TIMESTAMP__
|
40
|
+
__VENDOR__ __VERSION__
|
41
41
|
)
|
42
42
|
|
43
43
|
state :whitespace do
|
data/lib/rouge/lexers/java.rb
CHANGED
@@ -23,9 +23,9 @@ module Rouge
|
|
23
23
|
|
24
24
|
types = %w(boolean byte char double float int long short var void)
|
25
25
|
|
26
|
-
id = /[
|
27
|
-
const_name = /[
|
28
|
-
class_name = /[
|
26
|
+
id = /[[:alpha:]_][[:word:]]*/
|
27
|
+
const_name = /[[:upper:]][[:upper:][:digit:]_]*\b/
|
28
|
+
class_name = /[[:upper:]][[:alnum:]]*\b/
|
29
29
|
|
30
30
|
state :root do
|
31
31
|
rule %r/[^\S\n]+/, Text
|
@@ -50,10 +50,9 @@ module Rouge
|
|
50
50
|
rule %r/@#{id}/, Name::Decorator
|
51
51
|
rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
52
52
|
rule %r/(?:#{types.join('|')})\b/, Keyword::Type
|
53
|
-
rule %r/package\b/, Keyword::Namespace
|
54
53
|
rule %r/(?:true|false|null)\b/, Keyword::Constant
|
55
54
|
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
|
56
|
-
rule %r/import\b/, Keyword::Namespace, :import
|
55
|
+
rule %r/(?:import|package)\b/, Keyword::Namespace, :import
|
57
56
|
rule %r/"(\\\\|\\"|[^"])*"/, Str
|
58
57
|
rule %r/'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
|
59
58
|
rule %r/(\.)(#{id})/ do
|
data/lib/rouge/lexers/lua.rb
CHANGED
@@ -72,7 +72,10 @@ module Rouge
|
|
72
72
|
|
73
73
|
rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m|
|
74
74
|
name = m[0]
|
75
|
-
if
|
75
|
+
if name == "gsub"
|
76
|
+
token Name::Builtin
|
77
|
+
push :gsub
|
78
|
+
elsif self.builtins.include?(name)
|
76
79
|
token Name::Builtin
|
77
80
|
elsif name =~ /\./
|
78
81
|
a, b = name.split('.', 2)
|
@@ -98,6 +101,41 @@ module Rouge
|
|
98
101
|
rule %r(\(), Punctuation, :pop!
|
99
102
|
end
|
100
103
|
|
104
|
+
state :gsub do
|
105
|
+
rule %r/\)/, Punctuation, :pop!
|
106
|
+
rule %r/[(,]/, Punctuation
|
107
|
+
rule %r/\s+/, Text
|
108
|
+
rule %r/"/, Str::Regex, :regex
|
109
|
+
end
|
110
|
+
|
111
|
+
state :regex do
|
112
|
+
rule %r(") do
|
113
|
+
token Str::Regex
|
114
|
+
goto :regex_end
|
115
|
+
end
|
116
|
+
|
117
|
+
rule %r/\[\^?/, Str::Escape, :regex_group
|
118
|
+
rule %r/\\./, Str::Escape
|
119
|
+
rule %r{[(][?][:=<!]}, Str::Escape
|
120
|
+
rule %r/[{][\d,]+[}]/, Str::Escape
|
121
|
+
rule %r/[()?]/, Str::Escape
|
122
|
+
rule %r/./, Str::Regex
|
123
|
+
end
|
124
|
+
|
125
|
+
state :regex_end do
|
126
|
+
rule %r/[$]+/, Str::Regex, :pop!
|
127
|
+
rule(//) { pop! }
|
128
|
+
end
|
129
|
+
|
130
|
+
state :regex_group do
|
131
|
+
rule %r(/), Str::Escape
|
132
|
+
rule %r/\]/, Str::Escape, :pop!
|
133
|
+
rule %r/(\\)(.)/ do |m|
|
134
|
+
groups Str::Escape, Str::Regex
|
135
|
+
end
|
136
|
+
rule %r/./, Str::Regex
|
137
|
+
end
|
138
|
+
|
101
139
|
state :escape_sqs do
|
102
140
|
mixin :string_escape
|
103
141
|
mixin :sqs
|
@@ -10,7 +10,7 @@ module Rouge
|
|
10
10
|
@at_keywords ||= %w(
|
11
11
|
selector private protected public encode synchronized try
|
12
12
|
throw catch finally end property synthesize dynamic optional
|
13
|
-
interface implementation import
|
13
|
+
interface implementation import autoreleasepool
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
@@ -44,7 +44,7 @@ module Rouge
|
|
44
44
|
elsif base.at_builtins.include? m[1]
|
45
45
|
token base::Name::Builtin
|
46
46
|
else
|
47
|
-
token Error
|
47
|
+
token base::Error
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -201,6 +201,11 @@ module Rouge
|
|
201
201
|
rule %r/(?:#{KEYWORDS})\b(?![-.])/i, Keyword::Reserved
|
202
202
|
|
203
203
|
rule %r/-{1,2}\w+/, Name::Tag
|
204
|
+
|
205
|
+
rule %r/(\.)?([-\w]+)(\[)/ do |m|
|
206
|
+
groups Operator, Name::Function, Punctuation
|
207
|
+
push :bracket
|
208
|
+
end
|
204
209
|
|
205
210
|
rule %r/([\/\\~\w][-.:\/\\~\w]*)(\n)?/ do |m|
|
206
211
|
groups Name::Function, Text::Whitespace
|
data/lib/rouge/lexers/rust.rb
CHANGED
@@ -159,6 +159,7 @@ module Rouge
|
|
159
159
|
)x, Str::Char
|
160
160
|
|
161
161
|
rule %r/"/, Str, :string
|
162
|
+
rule %r/r(#*)".*?"\1/m, Str
|
162
163
|
|
163
164
|
# numbers
|
164
165
|
dot = /[.][0-9_]+/
|
@@ -185,16 +186,7 @@ module Rouge
|
|
185
186
|
state :string do
|
186
187
|
rule %r/"/, Str, :pop!
|
187
188
|
rule escapes, Str::Escape
|
188
|
-
rule %r
|
189
|
-
rule %r(
|
190
|
-
%
|
191
|
-
( [0-9]+ [$] )? # Parameter
|
192
|
-
[0#+-]* # Flag
|
193
|
-
( [0-9]+ [$]? )? # Width
|
194
|
-
( [.] [0-9]+ )? # Precision
|
195
|
-
[bcdfiostuxX?] # Type
|
196
|
-
)x, Str::Interpol
|
197
|
-
rule %r/[^%"\\]+/m, Str
|
189
|
+
rule %r/[^"\\]+/m, Str
|
198
190
|
end
|
199
191
|
end
|
200
192
|
end
|
data/lib/rouge/lexers/shell.rb
CHANGED
@@ -64,7 +64,7 @@ module Rouge
|
|
64
64
|
# here-string
|
65
65
|
rule %r/<<</, Operator
|
66
66
|
|
67
|
-
rule %r/(<<-?)(\s*)(
|
67
|
+
rule %r/(<<-?)(\s*)(['"]?)(\\?)(\w+)(\3)/ do |m|
|
68
68
|
groups Operator, Text, Str::Heredoc, Str::Heredoc, Name::Constant, Str::Heredoc
|
69
69
|
@heredocstr = Regexp.escape(m[5])
|
70
70
|
push :heredoc
|
data/lib/rouge/lexers/toml.rb
CHANGED
@@ -48,7 +48,10 @@ module Rouge
|
|
48
48
|
|
49
49
|
state :content do
|
50
50
|
mixin :basic
|
51
|
+
rule %r/"""/, Str, :mdq
|
51
52
|
rule %r/"/, Str, :dq
|
53
|
+
rule %r/'''/, Str, :msq
|
54
|
+
rule %r/'/, Str, :sq
|
52
55
|
mixin :esc_str
|
53
56
|
rule %r/\,/, Punctuation
|
54
57
|
rule %r/\[/, Punctuation, :array
|
@@ -56,8 +59,28 @@ module Rouge
|
|
56
59
|
|
57
60
|
state :dq do
|
58
61
|
rule %r/"/, Str, :pop!
|
62
|
+
rule %r/\n/, Error, :pop!
|
63
|
+
mixin :esc_str
|
64
|
+
rule %r/[^\\"\n]+/, Str
|
65
|
+
end
|
66
|
+
|
67
|
+
state :mdq do
|
68
|
+
rule %r/"""/, Str, :pop!
|
59
69
|
mixin :esc_str
|
60
70
|
rule %r/[^\\"]+/, Str
|
71
|
+
rule %r/"+/, Str
|
72
|
+
end
|
73
|
+
|
74
|
+
state :sq do
|
75
|
+
rule %r/'/, Str, :pop!
|
76
|
+
rule %r/\n/, Error, :pop!
|
77
|
+
rule %r/[^'\n]+/, Str
|
78
|
+
end
|
79
|
+
|
80
|
+
state :msq do
|
81
|
+
rule %r/'''/, Str, :pop!
|
82
|
+
rule %r/[^']+/, Str
|
83
|
+
rule %r/'+/, Str
|
61
84
|
end
|
62
85
|
|
63
86
|
state :esc_str do
|
@@ -18,6 +18,13 @@ module Rouge
|
|
18
18
|
filenames '*.ts', '*.d.ts'
|
19
19
|
|
20
20
|
mimetypes 'text/typescript'
|
21
|
+
|
22
|
+
prepend :statement do
|
23
|
+
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
|
24
|
+
groups Name::Label, Punctuation, Text, Punctuation
|
25
|
+
push :expr_start
|
26
|
+
end
|
27
|
+
end
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Varnish < RegexLexer
|
7
|
+
title 'Varnish'
|
8
|
+
desc 'The Varnish (high-performance web accelerator) configuration language'
|
9
|
+
|
10
|
+
tag 'varnish'
|
11
|
+
aliases 'varnishconf', 'VCL'
|
12
|
+
filenames '*.vcl'
|
13
|
+
mimetypes 'text/x-varnish'
|
14
|
+
|
15
|
+
LNUM = '[0-9]+'
|
16
|
+
DNUM = '([0-9]*"."[0-9]+)|([0-9]+"."[0-9]*)'
|
17
|
+
SPACE = '[ \f\n\r\t\v]+'
|
18
|
+
|
19
|
+
# backend acl
|
20
|
+
def self.keywords
|
21
|
+
@keywords ||= Set.new %w[
|
22
|
+
vcl set unset include import if else elseif elif elsif director probe
|
23
|
+
backend acl
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.functions
|
28
|
+
@functions ||= Set.new %w[
|
29
|
+
ban call hash_data new regsub regsuball return rollback
|
30
|
+
std.cache_req_body std.collect std.duration std.fileread std.healthy
|
31
|
+
std.integer std.ip std.log std.port std.querysort std.random std.real
|
32
|
+
std.real2time std.rollback std.set_ip_tos std.strstr std.syslog
|
33
|
+
std.time std.time2integer std.time2real std.timestamp std.tolower
|
34
|
+
std.toupper synth synthetic
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.variables
|
39
|
+
@variables ||= Set.new %w[
|
40
|
+
bereq bereq.backend bereq.between_bytes_timeout bereq.connect_timeout
|
41
|
+
bereq.first_byte_timeout bereq.method bereq.proto bereq.retries
|
42
|
+
bereq.uncacheable bereq.url bereq.xid beresp beresp.age
|
43
|
+
beresp.backend beresp.backend.ip beresp.backend.name beresp.do_esi
|
44
|
+
beresp.do_gunzip beresp.do_gzip beresp.do_stream beresp.grace
|
45
|
+
beresp.keep beresp.proto beresp.reason beresp.status
|
46
|
+
beresp.storage_hint beresp.ttl beresp.uncacheable beresp.was_304
|
47
|
+
client.identity client.ip local.ip now obj.age obj.grace obj.hits
|
48
|
+
obj.keep obj.proto obj.reason obj.status obj.ttl obj.uncacheable
|
49
|
+
remote.ip req req.backend_hint req.can_gzip req.esi req.esi_level
|
50
|
+
req.hash_always_miss req.hash_ignore_busy req.method req.proto
|
51
|
+
req.restarts req.ttl req.url req.xid resp resp.proto resp.reason
|
52
|
+
resp.status server.hostname server.identity server.ip
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# This is never used
|
57
|
+
# def self.routines
|
58
|
+
# @routines ||= Set.new %w[
|
59
|
+
# backend_error backend_fetch backend_response purge deliver fini hash
|
60
|
+
# hit init miss pass pipe recv synth
|
61
|
+
# ]
|
62
|
+
# end
|
63
|
+
|
64
|
+
state :root do
|
65
|
+
# long strings ({" ... "})
|
66
|
+
rule %r/\{".*?"}/m, Str::Single
|
67
|
+
|
68
|
+
# comments
|
69
|
+
rule %r'/\*.*?\*/'m, Comment::Multiline
|
70
|
+
rule %r'(?://|#).*', Comment::Single
|
71
|
+
|
72
|
+
rule %r/true|false/, Keyword::Constant
|
73
|
+
|
74
|
+
# "wildcard variables"
|
75
|
+
rule %r/(?:(?:be)?re(?:sp|q)|obj)\.http\.[\w.-]+/ do
|
76
|
+
token Name::Variable
|
77
|
+
end
|
78
|
+
|
79
|
+
rule %r/(sub)(#{SPACE})([\w-]+)/ do
|
80
|
+
groups Keyword, Text, Name::Function
|
81
|
+
end
|
82
|
+
|
83
|
+
# inline C (C{ ... }C)
|
84
|
+
rule %r/C\{/ do
|
85
|
+
token Comment::Preproc
|
86
|
+
push :inline_c
|
87
|
+
end
|
88
|
+
|
89
|
+
rule %r/[a-z_.-]+/i do |m|
|
90
|
+
next token Keyword if self.class.keywords.include? m[0]
|
91
|
+
next token Name::Function if self.class.functions.include? m[0]
|
92
|
+
next token Name::Variable if self.class.variables.include? m[0]
|
93
|
+
token Text
|
94
|
+
end
|
95
|
+
|
96
|
+
# duration
|
97
|
+
rule %r/(?:#{LNUM}|#{DNUM})(?:ms|[smhdwy])/, Num::Other
|
98
|
+
# size in bytes
|
99
|
+
rule %r/#{LNUM}[KMGT]?B/, Num::Other
|
100
|
+
# literal numeric values (integer/float)
|
101
|
+
rule %r/#{LNUM}/, Num::Integer
|
102
|
+
rule %r/#{DNUM}/, Num::Float
|
103
|
+
|
104
|
+
# standard strings
|
105
|
+
rule %r/"/, Str::Double, :string
|
106
|
+
|
107
|
+
rule %r'[&|+-]{2}|[<=>!*/+-]=|<<|>>|!~|[-+*/%><=!&|~]', Operator
|
108
|
+
|
109
|
+
rule %r/[{}();.,]/, Punctuation
|
110
|
+
|
111
|
+
rule %r/\r\n?|\n/, Text
|
112
|
+
rule %r/./, Text
|
113
|
+
end
|
114
|
+
|
115
|
+
state :string do
|
116
|
+
rule %r/"/, Str::Double, :pop!
|
117
|
+
rule %r/\\[\\"nt]/, Str::Escape
|
118
|
+
|
119
|
+
rule %r/\r\n?|\n/, Str::Double
|
120
|
+
rule %r/./, Str::Double
|
121
|
+
end
|
122
|
+
|
123
|
+
state :inline_c do
|
124
|
+
rule %r/}C/, Comment::Preproc, :pop!
|
125
|
+
rule %r/.*?(?=}C)/m do
|
126
|
+
delegate C
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
data/lib/rouge/version.rb
CHANGED
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: 3.
|
4
|
+
version: 3.16.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: 2020-
|
11
|
+
date: 2020-02-11 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:
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/rouge/demos/twig
|
194
194
|
- lib/rouge/demos/typescript
|
195
195
|
- lib/rouge/demos/vala
|
196
|
+
- lib/rouge/demos/varnish
|
196
197
|
- lib/rouge/demos/vb
|
197
198
|
- lib/rouge/demos/verilog
|
198
199
|
- lib/rouge/demos/vhdl
|
@@ -214,6 +215,7 @@ files:
|
|
214
215
|
- lib/rouge/formatters/html_table.rb
|
215
216
|
- lib/rouge/formatters/null.rb
|
216
217
|
- lib/rouge/formatters/terminal256.rb
|
218
|
+
- lib/rouge/formatters/terminal_truecolor.rb
|
217
219
|
- lib/rouge/formatters/tex.rb
|
218
220
|
- lib/rouge/guesser.rb
|
219
221
|
- lib/rouge/guessers/disambiguation.rb
|
@@ -405,6 +407,7 @@ files:
|
|
405
407
|
- lib/rouge/lexers/typescript.rb
|
406
408
|
- lib/rouge/lexers/typescript/common.rb
|
407
409
|
- lib/rouge/lexers/vala.rb
|
410
|
+
- lib/rouge/lexers/varnish.rb
|
408
411
|
- lib/rouge/lexers/vb.rb
|
409
412
|
- lib/rouge/lexers/verilog.rb
|
410
413
|
- lib/rouge/lexers/vhdl.rb
|