rouge 2.0.2 → 2.0.3
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.rb +5 -0
- data/lib/rouge/demos/tulip +3 -4
- data/lib/rouge/formatters/html_pygments.rb +1 -1
- data/lib/rouge/formatters/html_table.rb +4 -4
- data/lib/rouge/guesser.rb +9 -0
- data/lib/rouge/lexer.rb +1 -10
- data/lib/rouge/lexers/markdown.rb +1 -1
- data/lib/rouge/lexers/php.rb +1 -1
- data/lib/rouge/lexers/praat.rb +27 -24
- data/lib/rouge/lexers/ruby.rb +18 -9
- data/lib/rouge/lexers/tulip.rb +47 -45
- data/lib/rouge/regex_lexer.rb +5 -5
- data/lib/rouge/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93043d4d750807111180be1a7d6582d7d8338470
|
4
|
+
data.tar.gz: 9b99367f2a290e9c4c0a040142866a641bb06803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302965016c0054702b7a0e97c1d8fecb6a755ae4957e127870e2d6eecd4131d8589e4f20b6c44b751edcceb0d3030cdfa27004ac9388d6b44e72b0133451a6f9
|
7
|
+
data.tar.gz: 52de7875d8d80e34c93cec6c86afdf8292bebfeabcac389a746c18b95bd46bb070b9410020ca609bd4beec241fdf243a07792cc927a4b7832254005f007c40c1
|
data/lib/rouge.rb
CHANGED
data/lib/rouge/demos/tulip
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
# ref.tlp
|
2
1
|
@module ref
|
3
2
|
|
4
|
-
ref value =
|
3
|
+
ref value = Ref (spawn [ ! => loop value ])
|
5
4
|
|
6
5
|
loop value = receive [
|
7
6
|
.set new-value => loop new-value
|
8
|
-
p, .get =>
|
7
|
+
p, id, .get => { send p (id, value); loop value }
|
9
8
|
]
|
10
9
|
|
11
|
-
@
|
10
|
+
@object Ref pid [
|
12
11
|
set val = .set val > send pid
|
13
12
|
get! = .get > send-wait pid
|
14
13
|
]
|
@@ -41,16 +41,16 @@ module Rouge
|
|
41
41
|
sprintf("#{@line_format}", i) << "\n"
|
42
42
|
end.join('')
|
43
43
|
|
44
|
-
numbers =
|
44
|
+
numbers = %(<pre class="lineno">#{formatted_line_numbers}</pre>)
|
45
45
|
|
46
|
-
yield
|
46
|
+
yield %(<table class="#@table_class"><tbody><tr>)
|
47
47
|
|
48
48
|
# the "gl" class applies the style for Generic.Lineno
|
49
|
-
yield
|
49
|
+
yield %(<td class="#@gutter_class gl">)
|
50
50
|
yield numbers
|
51
51
|
yield '</td>'
|
52
52
|
|
53
|
-
yield
|
53
|
+
yield %(<td class="#@code_class"><pre>)
|
54
54
|
yield formatted
|
55
55
|
yield '</pre></td>'
|
56
56
|
|
data/lib/rouge/guesser.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
module Rouge
|
2
2
|
class Guesser
|
3
|
+
class Ambiguous < StandardError
|
4
|
+
attr_reader :alternatives
|
5
|
+
def initialize(alternatives); @alternatives = alternatives; end
|
6
|
+
|
7
|
+
def message
|
8
|
+
"Ambiguous guess: can't decide between #{alternatives.map(&:tag).inspect}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
3
12
|
def self.guess(guessers, lexers)
|
4
13
|
original_size = lexers.size
|
5
14
|
|
data/lib/rouge/lexer.rb
CHANGED
@@ -122,15 +122,6 @@ module Rouge
|
|
122
122
|
Guesser.guess(guessers, Lexer.all)
|
123
123
|
end
|
124
124
|
|
125
|
-
class AmbiguousGuess < StandardError
|
126
|
-
attr_reader :alternatives
|
127
|
-
def initialize(alternatives); @alternatives = alternatives; end
|
128
|
-
|
129
|
-
def message
|
130
|
-
"Ambiguous guess: can't decide between #{alternatives.map(&:tag).inspect}"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
125
|
# Guess which lexer to use based on a hash of info.
|
135
126
|
#
|
136
127
|
# @option info :mimetype
|
@@ -150,7 +141,7 @@ module Rouge
|
|
150
141
|
return Lexers::PlainText if lexers.empty?
|
151
142
|
return lexers[0] if lexers.size == 1
|
152
143
|
|
153
|
-
raise
|
144
|
+
raise Guesser::Ambiguous.new(lexers)
|
154
145
|
end
|
155
146
|
|
156
147
|
def guess_by_mimetype(mt)
|
data/lib/rouge/lexers/php.rb
CHANGED
data/lib/rouge/lexers/praat.rb
CHANGED
@@ -37,7 +37,7 @@ module Rouge
|
|
37
37
|
demoOptionKeyPressed demoShiftKeyPressed demoShow demoWaitForInput
|
38
38
|
demoWindowTitle demoX demoY differenceLimensToPhon do editor endPause
|
39
39
|
endSendPraat endsWith erb erbToHertz erf erfc exitScript exp
|
40
|
-
extractNumber fileReadable fisherP fisherQ floor gaussP gaussQ
|
40
|
+
extractNumber fileReadable fisherP fisherQ floor gaussP gaussQ hash
|
41
41
|
hertzToBark hertzToErb hertzToMel hertzToSemitones imax imin
|
42
42
|
incompleteBeta incompleteGammaP index index_regex integer invBinomialP
|
43
43
|
invBinomialQ invChiSquareQ invFisherQ invGaussQ invSigmoid invStudentQ
|
@@ -104,12 +104,21 @@ module Rouge
|
|
104
104
|
groups Text, Comment::Single
|
105
105
|
end
|
106
106
|
|
107
|
-
rule /^#.*?$/,
|
108
|
-
rule /;[^\n]*/,
|
109
|
-
rule /\s+/,
|
110
|
-
|
111
|
-
rule
|
112
|
-
|
107
|
+
rule /^#.*?$/, Comment::Single
|
108
|
+
rule /;[^\n]*/, Comment::Single
|
109
|
+
rule /\s+/, Text
|
110
|
+
|
111
|
+
rule /(\bprocedure)(\s+)/ do
|
112
|
+
groups Keyword, Text
|
113
|
+
push :procedure_definition
|
114
|
+
end
|
115
|
+
|
116
|
+
rule /(\bcall)(\s+)/ do
|
117
|
+
groups Keyword, Text
|
118
|
+
push :procedure_call
|
119
|
+
end
|
120
|
+
|
121
|
+
rule /@/, Name::Function, :procedure_call
|
113
122
|
|
114
123
|
mixin :function_call
|
115
124
|
|
@@ -142,7 +151,7 @@ module Rouge
|
|
142
151
|
end
|
143
152
|
|
144
153
|
state :command do
|
145
|
-
rule /( ?[
|
154
|
+
rule /( ?([^\s:\.'])+ ?)/, Keyword
|
146
155
|
mixin :string_interpolated
|
147
156
|
|
148
157
|
rule /\.{3}/ do
|
@@ -161,32 +170,26 @@ module Rouge
|
|
161
170
|
end
|
162
171
|
|
163
172
|
state :procedure_call do
|
164
|
-
|
173
|
+
mixin :string_interpolated
|
165
174
|
|
166
|
-
rule /(
|
167
|
-
groups Name::Function, Punctuation
|
168
|
-
pop!
|
169
|
-
end
|
175
|
+
rule /(:|\s*\()/, Punctuation, :pop!
|
170
176
|
|
171
|
-
rule /
|
172
|
-
|
177
|
+
rule /'/, Name::Function
|
178
|
+
rule /[^:\('\n\s]+/, Name::Function
|
179
|
+
|
180
|
+
rule /(?=\s+)/ do
|
181
|
+
token Text
|
173
182
|
pop!
|
174
183
|
push :old_arguments
|
175
184
|
end
|
176
185
|
end
|
177
186
|
|
178
187
|
state :procedure_definition do
|
179
|
-
rule
|
188
|
+
rule /(:|\s*\()/, Punctuation, :pop!
|
180
189
|
|
181
|
-
rule /
|
182
|
-
groups Name::Function, Text
|
183
|
-
pop!
|
184
|
-
end
|
190
|
+
rule /[^:\(\n\s]+/, Name::Function
|
185
191
|
|
186
|
-
rule /(
|
187
|
-
groups Name::Function, Text
|
188
|
-
pop!
|
189
|
-
end
|
192
|
+
rule /(\s+)/, Text, :pop!
|
190
193
|
end
|
191
194
|
|
192
195
|
state :function_call do
|
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -202,14 +202,6 @@ module Rouge
|
|
202
202
|
rule /(?<!\.)(?:#{builtins_g.join('|')})\b/,
|
203
203
|
Name::Builtin, :method_call
|
204
204
|
|
205
|
-
# char operator. ?x evaulates to "x", unless there's a digit
|
206
|
-
# beforehand like x>=0?n[x]:""
|
207
|
-
rule %r(
|
208
|
-
[?](\\[MC]-)* # modifiers
|
209
|
-
(\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
|
210
|
-
(?!\w)
|
211
|
-
)x, Str::Char
|
212
|
-
|
213
205
|
mixin :has_heredocs
|
214
206
|
|
215
207
|
rule /[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
|
@@ -223,7 +215,8 @@ module Rouge
|
|
223
215
|
rule /\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\.{1,3}/,
|
224
216
|
Operator, :expr_start
|
225
217
|
rule /[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
|
226
|
-
rule
|
218
|
+
rule(/[?]/) { token Punctuation; push :ternary; push :expr_start }
|
219
|
+
rule %r<[\[({,:\\;/]>, Punctuation, :expr_start
|
227
220
|
rule %r<[\])}]>, Punctuation
|
228
221
|
end
|
229
222
|
|
@@ -313,6 +306,12 @@ module Rouge
|
|
313
306
|
rule(//) { pop! }
|
314
307
|
end
|
315
308
|
|
309
|
+
state :ternary do
|
310
|
+
rule(/:(?!:)/) { token Punctuation; goto :expr_start }
|
311
|
+
|
312
|
+
mixin :root
|
313
|
+
end
|
314
|
+
|
316
315
|
state :defexpr do
|
317
316
|
rule /(\))(\.|::)?/ do
|
318
317
|
groups Punctuation, Operator
|
@@ -350,6 +349,8 @@ module Rouge
|
|
350
349
|
goto :expr_start
|
351
350
|
end
|
352
351
|
|
352
|
+
rule(/(?=\n)/) { pop! }
|
353
|
+
|
353
354
|
rule(//) { goto :method_call_spaced }
|
354
355
|
end
|
355
356
|
|
@@ -382,6 +383,14 @@ module Rouge
|
|
382
383
|
goto :slash_regex
|
383
384
|
end
|
384
385
|
|
386
|
+
# char operator. ?x evaulates to "x", unless there's a digit
|
387
|
+
# beforehand like x>=0?n[x]:""
|
388
|
+
rule %r(
|
389
|
+
[?](\\[MC]-)* # modifiers
|
390
|
+
(\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
|
391
|
+
(?!\w)
|
392
|
+
)x, Str::Char, :pop!
|
393
|
+
|
385
394
|
# special case for using a single space. Ruby demands that
|
386
395
|
# these be in a single line, otherwise it would make no sense.
|
387
396
|
rule /(\s*)(%[rqswQWxiI]? \S* )/ do
|
data/lib/rouge/lexers/tulip.rb
CHANGED
@@ -1,73 +1,75 @@
|
|
1
1
|
module Rouge
|
2
2
|
module Lexers
|
3
3
|
class Tulip < RegexLexer
|
4
|
+
desc 'the tulip programming language (twitter.com/tuliplang)'
|
4
5
|
tag 'tulip'
|
5
|
-
aliases '
|
6
|
+
aliases 'tulip'
|
7
|
+
|
6
8
|
filenames '*.tlp'
|
7
|
-
desc 'The tulip programming language http://github.com/jneen/tulip'
|
8
9
|
|
9
|
-
|
10
|
+
mimetypes 'text/x-tulip', 'application/x-tulip'
|
10
11
|
|
11
12
|
def self.analyze_text(text)
|
12
|
-
return 1 if text.shebang?
|
13
|
+
return 1 if text.shebang? 'tulip'
|
14
|
+
return 0
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
id = /[a-z][\w-]*/i
|
18
|
+
upper_id = /[A-Z][\w-]*/
|
19
|
+
|
20
|
+
state :comments_and_whitespace do
|
16
21
|
rule /\s+/, Text
|
17
|
-
rule
|
18
|
-
|
22
|
+
rule /#.*?$/, Comment
|
23
|
+
end
|
24
|
+
|
25
|
+
state :root do
|
26
|
+
mixin :comments_and_whitespace
|
27
|
+
|
19
28
|
rule /@#{id}/, Keyword
|
20
|
-
|
21
|
-
|
22
|
-
rule
|
23
|
-
|
24
|
-
rule
|
25
|
-
groups Name::
|
29
|
+
|
30
|
+
|
31
|
+
rule /[>,!\[\]:{}()=;\/]/, Punctuation
|
32
|
+
|
33
|
+
rule /(\\#{id})([{])/ do
|
34
|
+
groups Name::Variable, Str
|
35
|
+
push :nested_string
|
26
36
|
end
|
27
37
|
|
28
|
-
rule
|
29
|
-
rule /'?{/, Str, :string
|
30
|
-
rule /['"][^\s)\]]+/, Str
|
38
|
+
rule /\\#{id}/, Name::Function
|
31
39
|
|
32
|
-
rule /
|
40
|
+
rule /"/, Str, :dq
|
33
41
|
|
34
|
-
rule /
|
35
|
-
rule /[.][.][.]/, Punctuation
|
36
|
-
rule id, Name
|
37
|
-
end
|
42
|
+
rule /'{/, Str, :nested_string
|
38
43
|
|
39
|
-
|
40
|
-
rule /{
|
41
|
-
token Str; push
|
42
|
-
end
|
44
|
+
rule /[.]#{id}/, Name::Tag
|
45
|
+
rule /[$]#{id}/, Name::Variable
|
43
46
|
|
44
|
-
rule /
|
45
|
-
rule /[$]/, Str
|
46
|
-
rule /[^${}\\]+/, Str
|
47
|
-
end
|
47
|
+
rule /[0-9]+([.][0-9]+)?/, Num
|
48
48
|
|
49
|
-
|
50
|
-
mixin :string_base
|
51
|
-
rule /\\/, Str
|
52
|
-
end
|
49
|
+
rule /#{id}/, Name
|
53
50
|
|
54
|
-
|
55
|
-
rule(/[(]/) { token Punctuation; push }
|
56
|
-
rule /[)]/, Punctuation, :pop!
|
57
|
-
mixin :root
|
51
|
+
rule /</, Comment::Preproc, :angle_brackets
|
58
52
|
end
|
59
53
|
|
60
|
-
state :
|
61
|
-
rule /[
|
62
|
-
rule /
|
63
|
-
|
54
|
+
state :dq do
|
55
|
+
rule /[^\\"]+/, Str
|
56
|
+
rule /"/, Str, :pop!
|
57
|
+
rule /\\./, Str::Escape
|
64
58
|
end
|
65
59
|
|
66
|
-
state :
|
60
|
+
state :nested_string do
|
67
61
|
rule /\\./, Str::Escape
|
68
|
-
rule
|
69
|
-
rule
|
70
|
-
|
62
|
+
rule(/{/) { token Str; push :nested_string }
|
63
|
+
rule(/}/) { token Str; pop! }
|
64
|
+
rule(/[^{}\\]+/) { token Str }
|
65
|
+
end
|
66
|
+
|
67
|
+
state :angle_brackets do
|
68
|
+
mixin :comments_and_whitespace
|
69
|
+
rule />/, Comment::Preproc, :pop!
|
70
|
+
rule /[*:]/, Punctuation
|
71
|
+
rule /#{upper_id}/, Keyword::Type
|
72
|
+
rule /#{id}/, Name::Variable
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
data/lib/rouge/regex_lexer.rb
CHANGED
@@ -109,7 +109,7 @@ module Rouge
|
|
109
109
|
proc do |stream|
|
110
110
|
puts " yielding #{tok.qualname}, #{stream[0].inspect}" if @debug
|
111
111
|
@output_stream.call(tok, stream[0])
|
112
|
-
puts " pushing
|
112
|
+
puts " pushing :#{@stack.last.name}" if @debug
|
113
113
|
@stack.push(@stack.last)
|
114
114
|
end
|
115
115
|
when Symbol
|
@@ -117,7 +117,7 @@ module Rouge
|
|
117
117
|
puts " yielding #{tok.qualname}, #{stream[0].inspect}" if @debug
|
118
118
|
@output_stream.call(tok, stream[0])
|
119
119
|
state = @states[next_state] || self.class.get_state(next_state)
|
120
|
-
puts " pushing
|
120
|
+
puts " pushing :#{state.name}" if @debug
|
121
121
|
@stack.push(state)
|
122
122
|
end
|
123
123
|
when nil
|
@@ -261,7 +261,7 @@ module Rouge
|
|
261
261
|
until stream.eos?
|
262
262
|
if @debug
|
263
263
|
puts "lexer: #{self.class.tag}"
|
264
|
-
puts "stack: #{stack.map(&:name).inspect}"
|
264
|
+
puts "stack: #{stack.map(&:name).map(&:to_sym).inspect}"
|
265
265
|
puts "stream: #{stream.peek(20).inspect}"
|
266
266
|
end
|
267
267
|
|
@@ -385,7 +385,7 @@ module Rouge
|
|
385
385
|
self.state
|
386
386
|
end
|
387
387
|
|
388
|
-
puts " pushing
|
388
|
+
puts " pushing :#{push_state.name}" if @debug
|
389
389
|
stack.push(push_state)
|
390
390
|
end
|
391
391
|
|
@@ -405,7 +405,7 @@ module Rouge
|
|
405
405
|
def goto(state_name)
|
406
406
|
raise 'empty stack!' if stack.empty?
|
407
407
|
|
408
|
-
puts " going to state
|
408
|
+
puts " going to state :#{state_name} " if @debug
|
409
409
|
stack[-1] = get_state(state_name)
|
410
410
|
end
|
411
411
|
|
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: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeanine Adkisson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-14 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:
|