coderay 0.7.2.168 → 0.7.2.176
Sign up to get free protection for your applications and to get access to all the features.
- data/demo/demo_server.rb +1 -1
- data/lib/coderay/encoders/html/classes.rb +5 -2
- data/lib/coderay/helpers/filetype.rb +180 -180
- data/lib/coderay/helpers/gzip_simple.rb +122 -122
- data/lib/coderay/helpers/plugin.rb +326 -326
- data/lib/coderay/helpers/word_list.rb +106 -106
- data/lib/coderay/scanner.rb +2 -2
- data/lib/coderay/scanners/delphi.rb +2 -1
- data/lib/coderay/scanners/html.rb +3 -0
- data/lib/coderay/scanners/nitro_xhtml.rb +3 -0
- data/lib/coderay/scanners/ruby.rb +0 -40
- data/lib/coderay/styles/_map.rb +7 -7
- data/lib/coderay/styles/cycnus.rb +125 -125
- data/lib/coderay/styles/murphy.rb +119 -119
- data/lib/coderay/tokens.rb +48 -2
- metadata +37 -37
@@ -1,119 +1,119 @@
|
|
1
|
-
module CodeRay
|
2
|
-
module Styles
|
3
|
-
|
4
|
-
class Murphy < Style
|
5
|
-
|
6
|
-
register_for :murphy
|
7
|
-
|
8
|
-
code_background = '#001129'
|
9
|
-
numbers_background = code_background
|
10
|
-
border_color = 'silver'
|
11
|
-
normal_color = '#C0C0C0'
|
12
|
-
|
13
|
-
CSS_MAIN_STYLES = <<-MAIN
|
14
|
-
.CodeRay {
|
15
|
-
background-color: #{code_background};
|
16
|
-
border: 1px solid #{border_color};
|
17
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
18
|
-
color: #{normal_color};
|
19
|
-
}
|
20
|
-
.CodeRay pre { margin: 0px; }
|
21
|
-
|
22
|
-
div.CodeRay { }
|
23
|
-
|
24
|
-
span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
25
|
-
|
26
|
-
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
27
|
-
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
28
|
-
|
29
|
-
.CodeRay .line_numbers, .CodeRay .no {
|
30
|
-
background-color: #{numbers_background};
|
31
|
-
color: gray;
|
32
|
-
text-align: right;
|
33
|
-
}
|
34
|
-
.CodeRay .line_numbers tt { font-weight: bold; }
|
35
|
-
.CodeRay .no { padding: 0px 4px; }
|
36
|
-
.CodeRay .code { width: 100%; }
|
37
|
-
|
38
|
-
ol.CodeRay { font-size: 10pt; }
|
39
|
-
ol.CodeRay li { white-space: pre; }
|
40
|
-
|
41
|
-
.CodeRay .code pre { overflow: auto; }
|
42
|
-
MAIN
|
43
|
-
|
44
|
-
TOKEN_COLORS = <<-'TOKENS'
|
45
|
-
.af { color:#00C; }
|
46
|
-
.an { color:#007; }
|
47
|
-
.av { color:#700; }
|
48
|
-
.aw { color:#C00; }
|
49
|
-
.bi { color:#509; font-weight:bold; }
|
50
|
-
.c { color:#666; }
|
51
|
-
|
52
|
-
.ch { color:#88F; }
|
53
|
-
.ch .k { color:#04D; }
|
54
|
-
.ch .dl { color:#039; }
|
55
|
-
|
56
|
-
.cl { color:#e9e; font-weight:bold; }
|
57
|
-
.co { color:#5ED; font-weight:bold; }
|
58
|
-
.cr { color:#0A0; }
|
59
|
-
.cv { color:#ccf; }
|
60
|
-
.df { color:#099; font-weight:bold; }
|
61
|
-
.di { color:#088; font-weight:bold; }
|
62
|
-
.dl { color:black; }
|
63
|
-
.do { color:#970; }
|
64
|
-
.ds { color:#D42; font-weight:bold; }
|
65
|
-
.e { color:#666; font-weight:bold; }
|
66
|
-
.er { color:#F00; background-color:#FAA; }
|
67
|
-
.ex { color:#F00; font-weight:bold; }
|
68
|
-
.fl { color:#60E; font-weight:bold; }
|
69
|
-
.fu { color:#5ed; font-weight:bold; }
|
70
|
-
.gv { color:#f84; }
|
71
|
-
.hx { color:#058; font-weight:bold; }
|
72
|
-
.i { color:#66f; font-weight:bold; }
|
73
|
-
.ic { color:#B44; font-weight:bold; }
|
74
|
-
.il { }
|
75
|
-
.in { color:#B2B; font-weight:bold; }
|
76
|
-
.iv { color:#aaf; }
|
77
|
-
.la { color:#970; font-weight:bold; }
|
78
|
-
.lv { color:#963; }
|
79
|
-
.oc { color:#40E; font-weight:bold; }
|
80
|
-
.on { color:#000; font-weight:bold; }
|
81
|
-
.op { }
|
82
|
-
.pc { color:#08f; font-weight:bold; }
|
83
|
-
.pd { color:#369; font-weight:bold; }
|
84
|
-
.pp { color:#579; }
|
85
|
-
.pt { color:#66f; font-weight:bold; }
|
86
|
-
.r { color:#5de; font-weight:bold; }
|
87
|
-
|
88
|
-
.rx { background-color:#221133; }
|
89
|
-
.rx .k { color:#f8f; }
|
90
|
-
.rx .dl { color:#f0f; }
|
91
|
-
.rx .mod { color:#f0b; }
|
92
|
-
.rx .fu { color:#404; font-weight: bold; }
|
93
|
-
|
94
|
-
.s { background-color:#331122; }
|
95
|
-
.s .s { background-color:#ffe0e0; }
|
96
|
-
.s .s .s { background-color:#ffd0d0; }
|
97
|
-
.s .k { color:#F88; }
|
98
|
-
.s .dl { color:#f55; }
|
99
|
-
|
100
|
-
.sh { background-color:#f0fff0; }
|
101
|
-
.sh .k { color:#2B2; }
|
102
|
-
.sh .dl { color:#161; }
|
103
|
-
|
104
|
-
.sy { color:#Fc8; }
|
105
|
-
.sy .k { color:#Fc8; }
|
106
|
-
.sy .dl { color:#F84; }
|
107
|
-
|
108
|
-
.ta { color:#070; }
|
109
|
-
.tf { color:#070; font-weight:bold; }
|
110
|
-
.ts { color:#D70; font-weight:bold; }
|
111
|
-
.ty { color:#339; font-weight:bold; }
|
112
|
-
.v { color:#036; }
|
113
|
-
.xt { color:#444; }
|
114
|
-
TOKENS
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
1
|
+
module CodeRay
|
2
|
+
module Styles
|
3
|
+
|
4
|
+
class Murphy < Style
|
5
|
+
|
6
|
+
register_for :murphy
|
7
|
+
|
8
|
+
code_background = '#001129'
|
9
|
+
numbers_background = code_background
|
10
|
+
border_color = 'silver'
|
11
|
+
normal_color = '#C0C0C0'
|
12
|
+
|
13
|
+
CSS_MAIN_STYLES = <<-MAIN
|
14
|
+
.CodeRay {
|
15
|
+
background-color: #{code_background};
|
16
|
+
border: 1px solid #{border_color};
|
17
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
18
|
+
color: #{normal_color};
|
19
|
+
}
|
20
|
+
.CodeRay pre { margin: 0px; }
|
21
|
+
|
22
|
+
div.CodeRay { }
|
23
|
+
|
24
|
+
span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
25
|
+
|
26
|
+
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
27
|
+
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
28
|
+
|
29
|
+
.CodeRay .line_numbers, .CodeRay .no {
|
30
|
+
background-color: #{numbers_background};
|
31
|
+
color: gray;
|
32
|
+
text-align: right;
|
33
|
+
}
|
34
|
+
.CodeRay .line_numbers tt { font-weight: bold; }
|
35
|
+
.CodeRay .no { padding: 0px 4px; }
|
36
|
+
.CodeRay .code { width: 100%; }
|
37
|
+
|
38
|
+
ol.CodeRay { font-size: 10pt; }
|
39
|
+
ol.CodeRay li { white-space: pre; }
|
40
|
+
|
41
|
+
.CodeRay .code pre { overflow: auto; }
|
42
|
+
MAIN
|
43
|
+
|
44
|
+
TOKEN_COLORS = <<-'TOKENS'
|
45
|
+
.af { color:#00C; }
|
46
|
+
.an { color:#007; }
|
47
|
+
.av { color:#700; }
|
48
|
+
.aw { color:#C00; }
|
49
|
+
.bi { color:#509; font-weight:bold; }
|
50
|
+
.c { color:#666; }
|
51
|
+
|
52
|
+
.ch { color:#88F; }
|
53
|
+
.ch .k { color:#04D; }
|
54
|
+
.ch .dl { color:#039; }
|
55
|
+
|
56
|
+
.cl { color:#e9e; font-weight:bold; }
|
57
|
+
.co { color:#5ED; font-weight:bold; }
|
58
|
+
.cr { color:#0A0; }
|
59
|
+
.cv { color:#ccf; }
|
60
|
+
.df { color:#099; font-weight:bold; }
|
61
|
+
.di { color:#088; font-weight:bold; }
|
62
|
+
.dl { color:black; }
|
63
|
+
.do { color:#970; }
|
64
|
+
.ds { color:#D42; font-weight:bold; }
|
65
|
+
.e { color:#666; font-weight:bold; }
|
66
|
+
.er { color:#F00; background-color:#FAA; }
|
67
|
+
.ex { color:#F00; font-weight:bold; }
|
68
|
+
.fl { color:#60E; font-weight:bold; }
|
69
|
+
.fu { color:#5ed; font-weight:bold; }
|
70
|
+
.gv { color:#f84; }
|
71
|
+
.hx { color:#058; font-weight:bold; }
|
72
|
+
.i { color:#66f; font-weight:bold; }
|
73
|
+
.ic { color:#B44; font-weight:bold; }
|
74
|
+
.il { }
|
75
|
+
.in { color:#B2B; font-weight:bold; }
|
76
|
+
.iv { color:#aaf; }
|
77
|
+
.la { color:#970; font-weight:bold; }
|
78
|
+
.lv { color:#963; }
|
79
|
+
.oc { color:#40E; font-weight:bold; }
|
80
|
+
.on { color:#000; font-weight:bold; }
|
81
|
+
.op { }
|
82
|
+
.pc { color:#08f; font-weight:bold; }
|
83
|
+
.pd { color:#369; font-weight:bold; }
|
84
|
+
.pp { color:#579; }
|
85
|
+
.pt { color:#66f; font-weight:bold; }
|
86
|
+
.r { color:#5de; font-weight:bold; }
|
87
|
+
|
88
|
+
.rx { background-color:#221133; }
|
89
|
+
.rx .k { color:#f8f; }
|
90
|
+
.rx .dl { color:#f0f; }
|
91
|
+
.rx .mod { color:#f0b; }
|
92
|
+
.rx .fu { color:#404; font-weight: bold; }
|
93
|
+
|
94
|
+
.s { background-color:#331122; }
|
95
|
+
.s .s { background-color:#ffe0e0; }
|
96
|
+
.s .s .s { background-color:#ffd0d0; }
|
97
|
+
.s .k { color:#F88; }
|
98
|
+
.s .dl { color:#f55; }
|
99
|
+
|
100
|
+
.sh { background-color:#f0fff0; }
|
101
|
+
.sh .k { color:#2B2; }
|
102
|
+
.sh .dl { color:#161; }
|
103
|
+
|
104
|
+
.sy { color:#Fc8; }
|
105
|
+
.sy .k { color:#Fc8; }
|
106
|
+
.sy .dl { color:#F84; }
|
107
|
+
|
108
|
+
.ta { color:#070; }
|
109
|
+
.tf { color:#070; font-weight:bold; }
|
110
|
+
.ts { color:#D70; font-weight:bold; }
|
111
|
+
.ty { color:#339; font-weight:bold; }
|
112
|
+
.v { color:#036; }
|
113
|
+
.xt { color:#444; }
|
114
|
+
TOKENS
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
data/lib/coderay/tokens.rb
CHANGED
@@ -170,7 +170,7 @@ module CodeRay
|
|
170
170
|
print ' Tokens#optimize: before: %d - ' % size if $DEBUG
|
171
171
|
last_kind = last_text = nil
|
172
172
|
new = self.class.new
|
173
|
-
|
173
|
+
for text, kind in self
|
174
174
|
if text.is_a? String
|
175
175
|
if kind == last_kind
|
176
176
|
last_text << text
|
@@ -195,6 +195,51 @@ module CodeRay
|
|
195
195
|
def optimize!
|
196
196
|
replace optimize
|
197
197
|
end
|
198
|
+
|
199
|
+
# Ensure that all :open tokens have a correspondent :close one.
|
200
|
+
#
|
201
|
+
# TODO: Test this!
|
202
|
+
def fix
|
203
|
+
# Check token nesting using a stack of kinds.
|
204
|
+
opened = []
|
205
|
+
for token, kind in self
|
206
|
+
if token == :open
|
207
|
+
opened.push kind
|
208
|
+
elsif token == :close
|
209
|
+
expected = opened.pop
|
210
|
+
if kind != expected
|
211
|
+
# Unexpected :close; decide what to do based on the kind:
|
212
|
+
# - token was opened earlier: also close tokens in between
|
213
|
+
# - token was never opened: delete the :close (skip with next)
|
214
|
+
next unless opened.rindex expected
|
215
|
+
tokens << [:close, kind] until (kind = opened.pop) == expected
|
216
|
+
end
|
217
|
+
end
|
218
|
+
tokens << [token, kind]
|
219
|
+
end
|
220
|
+
# Close remaining opened tokens
|
221
|
+
tokens << [:close, kind] while kind = opened.pop
|
222
|
+
tokens
|
223
|
+
end
|
224
|
+
|
225
|
+
def fix!
|
226
|
+
replace fix
|
227
|
+
end
|
228
|
+
|
229
|
+
# Makes sure that:
|
230
|
+
# - newlines are single tokens
|
231
|
+
# (which means all other token are single-line)
|
232
|
+
# - there are no open tokens at the end the line
|
233
|
+
#
|
234
|
+
# This makes it simple for encoders that work line-oriented,
|
235
|
+
# like HTML with list-style numeration.
|
236
|
+
def split_into_lines
|
237
|
+
raise NotImplementedError
|
238
|
+
end
|
239
|
+
|
240
|
+
def split_into_lines!
|
241
|
+
replace split_into_lines
|
242
|
+
end
|
198
243
|
|
199
244
|
# Dumps the object into a String that can be saved
|
200
245
|
# in files or databases.
|
@@ -304,7 +349,8 @@ module CodeRay
|
|
304
349
|
|
305
350
|
# This method is not implemented due to speed reasons. Use Tokens.
|
306
351
|
def text_size
|
307
|
-
raise NotImplementedError,
|
352
|
+
raise NotImplementedError,
|
353
|
+
'This method is not implemented due to speed reasons.'
|
308
354
|
end
|
309
355
|
|
310
356
|
# A TokenStream cannot be dumped. Use Tokens.
|
metadata
CHANGED
@@ -3,8 +3,8 @@ 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.2.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.7.2.176
|
7
|
+
date: 2006-10-15 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
|
@@ -34,67 +34,67 @@ authors:
|
|
34
34
|
- murphy
|
35
35
|
files:
|
36
36
|
- "./lib/coderay.rb"
|
37
|
-
- "./lib/coderay/
|
37
|
+
- "./lib/coderay/tokens.rb"
|
38
38
|
- "./lib/coderay/encoder.rb"
|
39
|
-
- "./lib/coderay/
|
39
|
+
- "./lib/coderay/style.rb"
|
40
40
|
- "./lib/coderay/duo.rb"
|
41
|
-
- "./lib/coderay/
|
42
|
-
- "./lib/coderay/encoders/html.rb"
|
43
|
-
- "./lib/coderay/encoders/debug.rb"
|
44
|
-
- "./lib/coderay/encoders/xml.rb"
|
45
|
-
- "./lib/coderay/encoders/_map.rb"
|
46
|
-
- "./lib/coderay/encoders/div.rb"
|
41
|
+
- "./lib/coderay/scanner.rb"
|
47
42
|
- "./lib/coderay/encoders/tokens.rb"
|
48
|
-
- "./lib/coderay/encoders/
|
43
|
+
- "./lib/coderay/encoders/debug.rb"
|
44
|
+
- "./lib/coderay/encoders/text.rb"
|
45
|
+
- "./lib/coderay/encoders/page.rb"
|
49
46
|
- "./lib/coderay/encoders/null.rb"
|
50
|
-
- "./lib/coderay/encoders/statistic.rb"
|
51
47
|
- "./lib/coderay/encoders/yaml.rb"
|
52
48
|
- "./lib/coderay/encoders/span.rb"
|
53
|
-
- "./lib/coderay/encoders/
|
54
|
-
- "./lib/coderay/encoders/
|
49
|
+
- "./lib/coderay/encoders/count.rb"
|
50
|
+
- "./lib/coderay/encoders/statistic.rb"
|
51
|
+
- "./lib/coderay/encoders/xml.rb"
|
52
|
+
- "./lib/coderay/encoders/html.rb"
|
53
|
+
- "./lib/coderay/encoders/div.rb"
|
54
|
+
- "./lib/coderay/encoders/_map.rb"
|
55
55
|
- "./lib/coderay/encoders/html/classes.rb"
|
56
|
-
- "./lib/coderay/encoders/html/output.rb"
|
57
|
-
- "./lib/coderay/encoders/html/numerization.rb"
|
58
56
|
- "./lib/coderay/encoders/html/css.rb"
|
59
|
-
- "./lib/coderay/
|
60
|
-
- "./lib/coderay/
|
57
|
+
- "./lib/coderay/encoders/html/numerization.rb"
|
58
|
+
- "./lib/coderay/encoders/html/output.rb"
|
61
59
|
- "./lib/coderay/helpers/gzip_simple.rb"
|
60
|
+
- "./lib/coderay/helpers/filetype.rb"
|
62
61
|
- "./lib/coderay/helpers/word_list.rb"
|
63
|
-
- "./lib/coderay/
|
64
|
-
- "./lib/coderay/scanners/delphi.rb"
|
62
|
+
- "./lib/coderay/helpers/plugin.rb"
|
65
63
|
- "./lib/coderay/scanners/c.rb"
|
64
|
+
- "./lib/coderay/scanners/rhtml.rb"
|
65
|
+
- "./lib/coderay/scanners/html.rb"
|
66
66
|
- "./lib/coderay/scanners/plaintext.rb"
|
67
67
|
- "./lib/coderay/scanners/_map.rb"
|
68
|
-
- "./lib/coderay/scanners/
|
69
|
-
- "./lib/coderay/scanners/ruby.rb"
|
68
|
+
- "./lib/coderay/scanners/delphi.rb"
|
70
69
|
- "./lib/coderay/scanners/xml.rb"
|
70
|
+
- "./lib/coderay/scanners/ruby.rb"
|
71
71
|
- "./lib/coderay/scanners/nitro_xhtml.rb"
|
72
72
|
- "./lib/coderay/scanners/ruby/patterns.rb"
|
73
73
|
- "./lib/coderay/styles/cycnus.rb"
|
74
74
|
- "./lib/coderay/styles/murphy.rb"
|
75
75
|
- "./lib/coderay/styles/_map.rb"
|
76
|
+
- "./demo/demo_tokens.rb"
|
76
77
|
- "./demo/suite.rb"
|
77
|
-
- "./demo/demo_server.rb"
|
78
|
-
- "./demo/demo_load_encoder.rb"
|
79
|
-
- "./demo/demo_load_scanner.rb"
|
80
|
-
- "./demo/demo_more.rb"
|
81
78
|
- "./demo/demo_css.rb"
|
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"
|
82
87
|
- "./demo/demo_cache.rb"
|
88
|
+
- "./demo/demo_more.rb"
|
83
89
|
- "./demo/demo_html_list.rb"
|
90
|
+
- "./demo/demo_global_vars.rb"
|
84
91
|
- "./demo/demo_global_vars2.rb"
|
85
92
|
- "./demo/demo_stream2.rb"
|
86
|
-
- "./demo/
|
87
|
-
- "./demo/demo_div.rb"
|
88
|
-
- "./demo/demo_html2.rb"
|
89
|
-
- "./demo/demo_count.rb"
|
90
|
-
- "./demo/demo_simple.rb"
|
91
|
-
- "./demo/demo_scanner.rb"
|
93
|
+
- "./demo/demo_load_encoder.rb"
|
92
94
|
- "./demo/demo_stream.rb"
|
93
|
-
- "./demo/
|
94
|
-
- "./demo/
|
95
|
-
- "./demo/
|
96
|
-
- "./demo/demo_dump.rb"
|
97
|
-
- "./demo/demo_highlight.rb"
|
95
|
+
- "./demo/demo_scanner.rb"
|
96
|
+
- "./demo/demo_count.rb"
|
97
|
+
- "./demo/demo_server.rb"
|
98
98
|
- "./README"
|
99
99
|
- "./LICENSE"
|
100
100
|
- "./FOLDERS"
|