coderay 0.7.2.176 → 0.7.4.196
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.
- data/FOLDERS +1 -1
- data/README +16 -9
- data/lib/coderay.rb +2 -2
- data/lib/coderay/encoder.rb +1 -1
- data/lib/coderay/helpers/plugin.rb +4 -4
- data/lib/coderay/scanners/ruby.rb +22 -19
- data/lib/coderay/scanners/ruby/patterns.rb +15 -1
- metadata +64 -87
- data/demo/demo_cache.rb +0 -12
- data/demo/demo_count.rb +0 -10
- data/demo/demo_css.rb +0 -4
- data/demo/demo_div.rb +0 -19
- data/demo/demo_dump.rb +0 -15
- data/demo/demo_encoder.rb +0 -39
- data/demo/demo_global_vars.rb +0 -13
- data/demo/demo_global_vars2.rb +0 -28
- data/demo/demo_highlight.rb +0 -14
- data/demo/demo_html.rb +0 -394
- data/demo/demo_html2.rb +0 -11
- data/demo/demo_html_list.rb +0 -12
- data/demo/demo_load_encoder.rb +0 -25
- data/demo/demo_load_scanner.rb +0 -25
- data/demo/demo_more.rb +0 -205
- data/demo/demo_scanner.rb +0 -36
- data/demo/demo_server.rb +0 -110
- data/demo/demo_simple.rb +0 -10
- data/demo/demo_stream.rb +0 -25
- data/demo/demo_stream2.rb +0 -8
- data/demo/demo_tokens.rb +0 -3
- data/demo/suite.rb +0 -82
data/FOLDERS
CHANGED
data/README
CHANGED
@@ -24,7 +24,7 @@ Contact:: murphy rubychan de
|
|
24
24
|
Website:: coderay.rubychan.de[http://coderay.rubychan.de]
|
25
25
|
Old Website:: rd.cYcnus.de/coderay[http://rd.cYcnus.de/coderay]
|
26
26
|
License:: GNU LGPL; see LICENSE file in the main directory.
|
27
|
-
Subversion:: $Id: README
|
27
|
+
Subversion:: $Id: README 195 2006-10-18 10:32:41Z murphy $
|
28
28
|
|
29
29
|
-----
|
30
30
|
|
@@ -73,19 +73,26 @@ Please report errors in this documentation to <coderay cycnus de>.
|
|
73
73
|
|
74
74
|
=== Thanks to
|
75
75
|
|
76
|
-
* Caleb Clausen for writing RubyLexer (see
|
77
|
-
of very interesting
|
76
|
+
* Caleb Clausen for writing RubyLexer (see
|
77
|
+
http://rubyforge.org/projects/rubylexer) and lots of very interesting mail
|
78
|
+
traffic
|
79
|
+
* birkenfeld (Georg Brandl) and mitsuhiku (Arnim Ronacher) for PyKleur. You
|
80
|
+
guys rock!
|
78
81
|
* Jamis Buck for writing Syntax (see http://rubyforge.org/projects/syntax)
|
79
82
|
I got some useful ideas from it.
|
80
|
-
* Doug Kearns and everyone else who worked on ruby.vim - it not only helped me
|
81
|
-
but also gave me a wonderful target to reach for the Ruby
|
82
|
-
|
83
|
+
* Doug Kearns and everyone else who worked on ruby.vim - it not only helped me
|
84
|
+
coding CodeRay, but also gave me a wonderful target to reach for the Ruby
|
85
|
+
scanner.
|
86
|
+
* everyone who used CodeBB on http://www.rubyforen.de and
|
87
|
+
http://www.infhu.de/mx
|
83
88
|
* iGEL, magichisoka, manveru, WoN�Do and everyone I forgot from rubyforen.de
|
84
89
|
* Daniel and Dethix from ruby-mine.de
|
85
|
-
* Dookie (who is no longer with us...) and Leonidas from
|
90
|
+
* Dookie (who is no longer with us...) and Leonidas from
|
91
|
+
http://www.python-forum.de
|
86
92
|
* matz and all Ruby gods and gurus
|
87
|
-
* The inventors of: the computer, the internet, the true color display, HTML &
|
88
|
-
pizza, microwaves, guitars, scouting, programming, anime,
|
93
|
+
* The inventors of: the computer, the internet, the true color display, HTML &
|
94
|
+
CSS, VIM, RUBY, pizza, microwaves, guitars, scouting, programming, anime,
|
95
|
+
manga, coke and green ice tea.
|
89
96
|
|
90
97
|
Where would we be without all those people?
|
91
98
|
|
data/lib/coderay.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# = CodeRay Library
|
2
2
|
#
|
3
|
-
# $Id: coderay.rb
|
3
|
+
# $Id: coderay.rb 188 2006-10-17 11:18:01Z murphy $
|
4
4
|
#
|
5
5
|
# CodeRay is a Ruby library for syntax highlighting.
|
6
6
|
#
|
@@ -133,7 +133,7 @@ module CodeRay
|
|
133
133
|
# Minor: odd for beta, even for stable
|
134
134
|
# Teeny: development state
|
135
135
|
# Revision: Subversion Revision number (generated on rake)
|
136
|
-
|
136
|
+
VERSION = '0.7.4'
|
137
137
|
|
138
138
|
require 'coderay/tokens'
|
139
139
|
require 'coderay/scanner'
|
data/lib/coderay/encoder.rb
CHANGED
@@ -130,7 +130,7 @@ module CodeRay
|
|
130
130
|
# By default, it calls text_token or block_token, depending on
|
131
131
|
# whether +text+ is a String.
|
132
132
|
def token text, kind
|
133
|
-
if text.
|
133
|
+
if text.instance_of? ::String # Ruby 1.9: :open.is_a? String
|
134
134
|
text_token text, kind
|
135
135
|
elsif text.is_a? ::Symbol
|
136
136
|
block_token text, kind
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# = PluginHost
|
2
2
|
#
|
3
|
-
# $Id: plugin.rb
|
3
|
+
# $Id: plugin.rb 188 2006-10-17 11:18:01Z murphy $
|
4
4
|
#
|
5
5
|
# A simple subclass plugin system.
|
6
6
|
#
|
@@ -32,9 +32,9 @@ module PluginHost
|
|
32
32
|
PLUGIN_HOSTS = []
|
33
33
|
PLUGIN_HOSTS_BY_ID = {} # dummy hash
|
34
34
|
|
35
|
-
# Loads all plugins using
|
35
|
+
# Loads all plugins using list and load.
|
36
36
|
def load_all
|
37
|
-
for plugin in
|
37
|
+
for plugin in list
|
38
38
|
load plugin
|
39
39
|
end
|
40
40
|
end
|
@@ -160,7 +160,7 @@ module PluginHost
|
|
160
160
|
# Returns an array of all .rb files in the plugin path.
|
161
161
|
#
|
162
162
|
# The extension .rb is not included.
|
163
|
-
def
|
163
|
+
def list
|
164
164
|
Dir[path_to('*')].select do |file|
|
165
165
|
File.basename(file)[/^(?!_)\w+\.rb$/]
|
166
166
|
end.map do |file|
|
@@ -24,7 +24,7 @@ module Scanners
|
|
24
24
|
private
|
25
25
|
def scan_tokens tokens, options
|
26
26
|
last_token_dot = false
|
27
|
-
|
27
|
+
value_expected = true
|
28
28
|
heredocs = nil
|
29
29
|
last_state = nil
|
30
30
|
state = :initial
|
@@ -68,7 +68,7 @@ module Scanners
|
|
68
68
|
tokens << [modifiers, :modifier] unless modifiers.empty?
|
69
69
|
end
|
70
70
|
tokens << [:close, state.type]
|
71
|
-
|
71
|
+
value_expected = false
|
72
72
|
state = state.next_state
|
73
73
|
|
74
74
|
when '\\'
|
@@ -93,7 +93,7 @@ module Scanners
|
|
93
93
|
case peek(1)[0]
|
94
94
|
when ?{
|
95
95
|
inline_block_stack << [state, depth, heredocs]
|
96
|
-
|
96
|
+
value_expected = true
|
97
97
|
state = :initial
|
98
98
|
depth = 1
|
99
99
|
tokens << [:open, :inline]
|
@@ -123,7 +123,6 @@ module Scanners
|
|
123
123
|
# {{{
|
124
124
|
if match = scan(/ [ \t\f]+ | \\? \n | \# .* /x) or
|
125
125
|
( bol? and match = scan(/#{patterns::RUBYDOC_OR_DATA}/o) )
|
126
|
-
fancy_allowed = true
|
127
126
|
case m = match[0]
|
128
127
|
when ?\s, ?\t, ?\f
|
129
128
|
match << scan(/\s*/) unless eos? or heredocs
|
@@ -131,7 +130,7 @@ module Scanners
|
|
131
130
|
when ?\n, ?\\
|
132
131
|
kind = :space
|
133
132
|
if m == ?\n
|
134
|
-
|
133
|
+
value_expected = true # FIXME not quite true
|
135
134
|
state = :initial if state == :undef_comma_expected
|
136
135
|
end
|
137
136
|
if heredocs
|
@@ -145,9 +144,10 @@ module Scanners
|
|
145
144
|
end
|
146
145
|
when ?#, ?=, ?_
|
147
146
|
kind = :comment
|
148
|
-
|
147
|
+
value_expected = true
|
149
148
|
else
|
150
|
-
raise_inspect 'else-case _ reached, because case %p was
|
149
|
+
raise_inspect 'else-case _ reached, because case %p was
|
150
|
+
not handled' % [matched[0].chr], tokens
|
151
151
|
end
|
152
152
|
tokens << [match, kind]
|
153
153
|
next
|
@@ -167,13 +167,17 @@ module Scanners
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
## experimental!
|
170
|
-
|
170
|
+
value_expected = :set if
|
171
|
+
patterns::REGEXP_ALLOWED[match] or check(/#{patterns::VALUE_FOLLOWS}/o)
|
172
|
+
|
173
|
+
elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o)
|
174
|
+
kind = :ident
|
175
|
+
value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o)
|
171
176
|
|
172
177
|
# OPERATORS #
|
173
|
-
elsif
|
174
|
-
(last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o))
|
178
|
+
elsif not last_token_dot and match = scan(/ ==?=? | \.\.?\.? | [\(\)\[\]\{\}] | :: | , /x)
|
175
179
|
if match !~ / [.\)\]\}] /x or match =~ /\.\.\.?/
|
176
|
-
|
180
|
+
value_expected = :set
|
177
181
|
end
|
178
182
|
last_token_dot = :set if match == '.' or match == '::'
|
179
183
|
kind = :operator
|
@@ -200,7 +204,7 @@ module Scanners
|
|
200
204
|
elsif match = scan(/#{patterns::INSTANCE_VARIABLE}/o)
|
201
205
|
kind = :instance_variable
|
202
206
|
|
203
|
-
elsif
|
207
|
+
elsif value_expected and match = scan(/\//)
|
204
208
|
tokens << [:open, :regexp]
|
205
209
|
kind = :delimiter
|
206
210
|
interpreted = true
|
@@ -222,10 +226,10 @@ module Scanners
|
|
222
226
|
end
|
223
227
|
|
224
228
|
elsif match = scan(/ [-+!~^]=? | [*|&]{1,2}=? | >>? /x)
|
225
|
-
|
229
|
+
value_expected = :set
|
226
230
|
kind = :operator
|
227
231
|
|
228
|
-
elsif
|
232
|
+
elsif value_expected and match = scan(/#{patterns::HEREDOC_OPEN}/o)
|
229
233
|
indented = self[1] == '-'
|
230
234
|
quote = self[3]
|
231
235
|
delim = self[quote ? 4 : 2]
|
@@ -237,7 +241,7 @@ module Scanners
|
|
237
241
|
heredocs ||= [] # create heredocs if empty
|
238
242
|
heredocs << heredoc
|
239
243
|
|
240
|
-
elsif
|
244
|
+
elsif value_expected and match = scan(/#{patterns::FANCY_START_CORRECT}/o)
|
241
245
|
kind, interpreted = *patterns::FancyStringType.fetch(self[1]) do
|
242
246
|
raise_inspect 'Unknown fancy string: %%%p' % k, tokens
|
243
247
|
end
|
@@ -245,11 +249,11 @@ module Scanners
|
|
245
249
|
state = patterns::StringState.new kind, interpreted, self[2]
|
246
250
|
kind = :delimiter
|
247
251
|
|
248
|
-
elsif
|
252
|
+
elsif value_expected and match = scan(/#{patterns::CHARACTER}/o)
|
249
253
|
kind = :integer
|
250
254
|
|
251
255
|
elsif match = scan(/ [\/%]=? | <(?:<|=>?)? | [?:;] /x)
|
252
|
-
|
256
|
+
value_expected = :set
|
253
257
|
kind = :operator
|
254
258
|
|
255
259
|
elsif match = scan(/`/)
|
@@ -326,8 +330,7 @@ module Scanners
|
|
326
330
|
end
|
327
331
|
# }}}
|
328
332
|
|
329
|
-
|
330
|
-
fancy_allowed = fancy_allowed == :set
|
333
|
+
value_expected = value_expected == :set
|
331
334
|
last_token_dot = last_token_dot == :set
|
332
335
|
|
333
336
|
if $DEBUG and not kind
|
@@ -21,7 +21,8 @@ module Scanners
|
|
21
21
|
add(MODULE_KEYWORDS, :module_expected)
|
22
22
|
|
23
23
|
IDENTS_ALLOWING_REGEXP = %w[
|
24
|
-
and or not while until unless if then elsif when sub sub! gsub gsub!
|
24
|
+
and or not while until unless if then elsif when sub sub! gsub gsub!
|
25
|
+
scan slice slice! split
|
25
26
|
]
|
26
27
|
REGEXP_ALLOWED = WordList.new(false).
|
27
28
|
add(IDENTS_ALLOWING_REGEXP, :set)
|
@@ -126,6 +127,19 @@ module Scanners
|
|
126
127
|
.*?
|
127
128
|
(?: \Z | (?=^\#CODE) )
|
128
129
|
/mx
|
130
|
+
|
131
|
+
# Checks for a valid value to follow. This enables
|
132
|
+
# fancy_allowed in method calls.
|
133
|
+
VALUE_FOLLOWS = /
|
134
|
+
\s+
|
135
|
+
(?:
|
136
|
+
[%\/][^\s=]
|
137
|
+
|
|
138
|
+
<<-?\S
|
139
|
+
|
|
140
|
+
#{CHARACTER}
|
141
|
+
)
|
142
|
+
/x
|
129
143
|
|
130
144
|
RUBYDOC_OR_DATA = / #{RUBYDOC} | #{DATA} /xo
|
131
145
|
|
metadata
CHANGED
@@ -3,114 +3,91 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: coderay
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.
|
7
|
-
date: 2006-10-
|
6
|
+
version: 0.7.4.196
|
7
|
+
date: 2006-10-18 00:00:00 +02:00
|
8
8
|
summary: CodeRay is a fast syntax highlighter engine for many languages.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: murphy@cYcnus.de
|
12
12
|
homepage: http://coderay.rubychan.de
|
13
13
|
rubyforge_project: coderay
|
14
|
-
description: "CodeRay is a Ruby library for syntax highlighting. I try to make CodeRay easy to
|
15
|
-
use and intuitive, but at the same time fully featured, complete, fast and
|
16
|
-
efficient. Usage is simple: require 'coderay' code = 'some %q(weird (Ruby)
|
17
|
-
can't shock) me!' puts CodeRay.scan(code, :ruby).html"
|
14
|
+
description: "CodeRay is a Ruby library for syntax highlighting. I try to make CodeRay easy to use and intuitive, but at the same time fully featured, complete, fast and efficient. Usage is simple: require 'coderay' code = 'some %q(weird (Ruby) can't shock) me!' puts CodeRay.scan(code, :ruby).html"
|
18
15
|
autorequire: coderay
|
19
16
|
default_executable:
|
20
17
|
bindir: bin
|
21
18
|
has_rdoc: true
|
22
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
23
20
|
requirements:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
version: 1.8.2
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.2
|
28
24
|
version:
|
29
25
|
platform: ruby
|
30
26
|
signing_key:
|
31
27
|
cert_chain:
|
32
28
|
post_install_message:
|
33
29
|
authors:
|
34
|
-
|
30
|
+
- murphy
|
35
31
|
files:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
- "./demo/demo_div.rb"
|
80
|
-
- "./demo/demo_highlight.rb"
|
81
|
-
- "./demo/demo_simple.rb"
|
82
|
-
- "./demo/demo_encoder.rb"
|
83
|
-
- "./demo/demo_html2.rb"
|
84
|
-
- "./demo/demo_load_scanner.rb"
|
85
|
-
- "./demo/demo_html.rb"
|
86
|
-
- "./demo/demo_dump.rb"
|
87
|
-
- "./demo/demo_cache.rb"
|
88
|
-
- "./demo/demo_more.rb"
|
89
|
-
- "./demo/demo_html_list.rb"
|
90
|
-
- "./demo/demo_global_vars.rb"
|
91
|
-
- "./demo/demo_global_vars2.rb"
|
92
|
-
- "./demo/demo_stream2.rb"
|
93
|
-
- "./demo/demo_load_encoder.rb"
|
94
|
-
- "./demo/demo_stream.rb"
|
95
|
-
- "./demo/demo_scanner.rb"
|
96
|
-
- "./demo/demo_count.rb"
|
97
|
-
- "./demo/demo_server.rb"
|
98
|
-
- "./README"
|
99
|
-
- "./LICENSE"
|
100
|
-
- "./FOLDERS"
|
32
|
+
- ./lib/coderay.rb
|
33
|
+
- ./lib/coderay/duo.rb
|
34
|
+
- ./lib/coderay/encoder.rb
|
35
|
+
- ./lib/coderay/scanner.rb
|
36
|
+
- ./lib/coderay/style.rb
|
37
|
+
- ./lib/coderay/tokens.rb
|
38
|
+
- ./lib/coderay/encoders/_map.rb
|
39
|
+
- ./lib/coderay/encoders/count.rb
|
40
|
+
- ./lib/coderay/encoders/debug.rb
|
41
|
+
- ./lib/coderay/encoders/div.rb
|
42
|
+
- ./lib/coderay/encoders/html.rb
|
43
|
+
- ./lib/coderay/encoders/null.rb
|
44
|
+
- ./lib/coderay/encoders/page.rb
|
45
|
+
- ./lib/coderay/encoders/span.rb
|
46
|
+
- ./lib/coderay/encoders/statistic.rb
|
47
|
+
- ./lib/coderay/encoders/text.rb
|
48
|
+
- ./lib/coderay/encoders/tokens.rb
|
49
|
+
- ./lib/coderay/encoders/xml.rb
|
50
|
+
- ./lib/coderay/encoders/yaml.rb
|
51
|
+
- ./lib/coderay/encoders/html/classes.rb
|
52
|
+
- ./lib/coderay/encoders/html/css.rb
|
53
|
+
- ./lib/coderay/encoders/html/numerization.rb
|
54
|
+
- ./lib/coderay/encoders/html/output.rb
|
55
|
+
- ./lib/coderay/helpers/filetype.rb
|
56
|
+
- ./lib/coderay/helpers/gzip_simple.rb
|
57
|
+
- ./lib/coderay/helpers/plugin.rb
|
58
|
+
- ./lib/coderay/helpers/word_list.rb
|
59
|
+
- ./lib/coderay/scanners/_map.rb
|
60
|
+
- ./lib/coderay/scanners/c.rb
|
61
|
+
- ./lib/coderay/scanners/delphi.rb
|
62
|
+
- ./lib/coderay/scanners/html.rb
|
63
|
+
- ./lib/coderay/scanners/nitro_xhtml.rb
|
64
|
+
- ./lib/coderay/scanners/plaintext.rb
|
65
|
+
- ./lib/coderay/scanners/rhtml.rb
|
66
|
+
- ./lib/coderay/scanners/ruby.rb
|
67
|
+
- ./lib/coderay/scanners/xml.rb
|
68
|
+
- ./lib/coderay/scanners/ruby/patterns.rb
|
69
|
+
- ./lib/coderay/styles/_map.rb
|
70
|
+
- ./lib/coderay/styles/cycnus.rb
|
71
|
+
- ./lib/coderay/styles/murphy.rb
|
72
|
+
- ./README
|
73
|
+
- ./LICENSE
|
74
|
+
- ./FOLDERS
|
101
75
|
test_files: []
|
76
|
+
|
102
77
|
rdoc_options:
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
78
|
+
- -SNw2
|
79
|
+
- -mREADME
|
80
|
+
- -a
|
81
|
+
- -t CodeRay Documentation
|
107
82
|
extra_rdoc_files:
|
108
|
-
|
109
|
-
|
83
|
+
- ./README
|
84
|
+
- ./FOLDERS
|
110
85
|
executables:
|
111
|
-
|
112
|
-
|
86
|
+
- coderay
|
87
|
+
- coderay_stylesheet
|
113
88
|
extensions: []
|
89
|
+
|
114
90
|
requirements:
|
115
|
-
|
116
|
-
dependencies: []
|
91
|
+
- strscan
|
92
|
+
dependencies: []
|
93
|
+
|
data/demo/demo_cache.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'coderay'
|
2
|
-
|
3
|
-
html_encoder = CodeRay.encoder :html
|
4
|
-
|
5
|
-
scanner = Hash.new do |h, lang|
|
6
|
-
h[lang] = CodeRay.scanner lang
|
7
|
-
end
|
8
|
-
|
9
|
-
for lang in [:ruby, :html]
|
10
|
-
tokens = scanner[lang].tokenize 'test <test>'
|
11
|
-
puts html_encoder.encode_tokens(tokens)
|
12
|
-
end
|