coderay 1.0.0.815pre → 1.0.0.831pre
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/coderay.rb +6 -9
- data/lib/coderay/encoders/_map.rb +2 -1
- data/lib/coderay/encoders/html.rb +0 -1
- data/lib/coderay/encoders/html/numbering.rb +1 -1
- data/lib/coderay/encoders/html/output.rb +2 -2
- data/lib/coderay/encoders/terminal.rb +2 -4
- data/lib/coderay/encoders/yaml.rb +3 -5
- data/lib/coderay/helpers/word_list.rb +3 -3
- data/lib/coderay/scanner.rb +6 -8
- data/lib/coderay/scanners/c.rb +1 -1
- data/lib/coderay/scanners/cpp.rb +1 -1
- data/lib/coderay/scanners/delphi.rb +2 -2
- data/lib/coderay/scanners/diff.rb +3 -1
- data/lib/coderay/scanners/groovy.rb +1 -1
- data/lib/coderay/scanners/html.rb +7 -8
- data/lib/coderay/scanners/java.rb +1 -1
- data/lib/coderay/scanners/java_script.rb +1 -1
- data/lib/coderay/scanners/php.rb +1 -1
- data/lib/coderay/scanners/python.rb +2 -2
- data/lib/coderay/scanners/ruby.rb +1 -1
- data/lib/coderay/scanners/sql.rb +2 -2
- data/lib/coderay/scanners/yaml.rb +2 -2
- data/lib/coderay/styles/alpha.rb +85 -98
- data/lib/coderay/token_kinds.rb +66 -67
- data/test/functional/basic.rb +5 -7
- data/test/functional/examples.rb +4 -4
- metadata +23 -48
- data/lib/coderay/styles/cycnus.rb +0 -144
- data/lib/coderay/styles/murphy.rb +0 -123
data/lib/coderay.rb
CHANGED
@@ -159,8 +159,7 @@ module CodeRay
|
|
159
159
|
# See also demo/demo_simple.
|
160
160
|
def scan code, lang, options = {}, &block
|
161
161
|
# FIXME: return a proxy for direct-stream encoding
|
162
|
-
scanner
|
163
|
-
scanner.tokenize
|
162
|
+
scanner(lang, options, &block).tokenize code
|
164
163
|
end
|
165
164
|
|
166
165
|
# Scans +filename+ (a path to a code file) with the Scanner for +lang+.
|
@@ -175,11 +174,9 @@ module CodeRay
|
|
175
174
|
# require 'coderay'
|
176
175
|
# page = CodeRay.scan_file('some_c_code.c').html
|
177
176
|
def scan_file filename, lang = :auto, options = {}, &block
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
end
|
182
|
-
scan file, lang, options = {}, &block
|
177
|
+
lang = FileType.fetch filename, :text, true if lang == :auto
|
178
|
+
code = File.read filename
|
179
|
+
scan code, lang, options = {}, &block
|
183
180
|
end
|
184
181
|
|
185
182
|
# Encode a string.
|
@@ -261,8 +258,8 @@ module CodeRay
|
|
261
258
|
# +options+ to it.
|
262
259
|
#
|
263
260
|
# See Scanner.new.
|
264
|
-
def scanner lang, options = {}
|
265
|
-
Scanners[lang].new '', options
|
261
|
+
def scanner lang, options = {}, &block
|
262
|
+
Scanners[lang].new '', options, &block
|
266
263
|
end
|
267
264
|
|
268
265
|
# Extract the options for the scanner from the +options+ hash.
|
@@ -84,7 +84,7 @@ module Encoders
|
|
84
84
|
line_number_text = bolding.call line_number
|
85
85
|
indent = ' ' * (max_width - line_number.to_s.size) # TODO: Optimize (10^x)
|
86
86
|
line_number += 1
|
87
|
-
"<span class=\"
|
87
|
+
"<span class=\"line-numbers\">#{indent}#{line_number_text}</span>#{open}#{line}#{close}\n"
|
88
88
|
end
|
89
89
|
|
90
90
|
when :table
|
@@ -124,7 +124,7 @@ module Encoders
|
|
124
124
|
|
125
125
|
TABLE = Template.new <<-TABLE
|
126
126
|
<table class="CodeRay"><tr>
|
127
|
-
<td class="
|
127
|
+
<td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><%LINE_NUMBERS%></pre></td>
|
128
128
|
<td class="code"><pre><%CONTENT%></pre></td>
|
129
129
|
</tr></table>
|
130
130
|
TABLE
|
@@ -136,7 +136,7 @@ module Encoders
|
|
136
136
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
137
137
|
<title></title>
|
138
138
|
<style type="text/css">
|
139
|
-
.CodeRay .
|
139
|
+
.CodeRay .line-numbers a {
|
140
140
|
text-decoration: inherit;
|
141
141
|
color: inherit;
|
142
142
|
}
|
@@ -22,7 +22,7 @@ module CodeRay
|
|
22
22
|
:annotation => '35',
|
23
23
|
:attribute_name => '33',
|
24
24
|
:attribute_value => '31',
|
25
|
-
:
|
25
|
+
:binary => '1;35',
|
26
26
|
:char => {
|
27
27
|
:self => '36', :delimiter => '34'
|
28
28
|
},
|
@@ -47,11 +47,10 @@ module CodeRay
|
|
47
47
|
:hex => '1;36',
|
48
48
|
:include => '33',
|
49
49
|
:integer => '1;34',
|
50
|
-
:interpreted => '1;35',
|
51
50
|
:key => '35',
|
52
51
|
:label => '1;15',
|
53
52
|
:local_variable => '33',
|
54
|
-
:
|
53
|
+
:octal => '1;35',
|
55
54
|
:operator_name => '1;29',
|
56
55
|
:predefined_constant => '1;36',
|
57
56
|
:predefined_type => '1;30',
|
@@ -79,7 +78,6 @@ module CodeRay
|
|
79
78
|
},
|
80
79
|
:symbol => '1;32',
|
81
80
|
:tag => '34',
|
82
|
-
:tag_special => ['34', '4'],
|
83
81
|
:type => '1;34',
|
84
82
|
:value => '36',
|
85
83
|
:variable => '34',
|
@@ -1,3 +1,5 @@
|
|
1
|
+
autoload :YAML, 'yaml'
|
2
|
+
|
1
3
|
module CodeRay
|
2
4
|
module Encoders
|
3
5
|
|
@@ -6,8 +8,6 @@ module Encoders
|
|
6
8
|
# Slow.
|
7
9
|
class YAML < Encoder
|
8
10
|
|
9
|
-
autoload :YAML, 'yaml'
|
10
|
-
|
11
11
|
register_for :yaml
|
12
12
|
|
13
13
|
FILE_EXTENSION = 'yaml'
|
@@ -20,9 +20,7 @@ module Encoders
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def finish options
|
23
|
-
YAML.dump
|
24
|
-
|
25
|
-
super
|
23
|
+
output ::YAML.dump(@data)
|
26
24
|
end
|
27
25
|
|
28
26
|
public
|
@@ -15,7 +15,7 @@ module CodeRay
|
|
15
15
|
# WordList is optimized to be used in Scanners,
|
16
16
|
# typically to decide whether a given ident is a special token.
|
17
17
|
#
|
18
|
-
# For case insensitive words use
|
18
|
+
# For case insensitive words use WordList::CaseIgnoring.
|
19
19
|
#
|
20
20
|
# Example:
|
21
21
|
#
|
@@ -60,9 +60,9 @@ module CodeRay
|
|
60
60
|
end
|
61
61
|
|
62
62
|
|
63
|
-
# A
|
63
|
+
# A CaseIgnoring WordList is like a WordList, only that
|
64
64
|
# keys are compared case-insensitively (normalizing keys using +downcase+).
|
65
|
-
class
|
65
|
+
class WordList::CaseIgnoring < WordList
|
66
66
|
|
67
67
|
def [] key
|
68
68
|
super key.downcase
|
data/lib/coderay/scanner.rb
CHANGED
@@ -4,8 +4,6 @@ require 'strscan'
|
|
4
4
|
module CodeRay
|
5
5
|
|
6
6
|
autoload :WordList, 'coderay/helpers/word_list'
|
7
|
-
# FIXME: Rename CaseIgnoringWordList to WordList::CaseIgnoring.
|
8
|
-
autoload :CaseIgnoringWordList, 'coderay/helpers/word_list'
|
9
7
|
|
10
8
|
# = Scanners
|
11
9
|
#
|
@@ -71,6 +69,8 @@ module CodeRay
|
|
71
69
|
def normalize code
|
72
70
|
# original = code
|
73
71
|
code = code.to_s unless code.is_a? ::String
|
72
|
+
return code if code.empty?
|
73
|
+
|
74
74
|
if code.respond_to? :encoding
|
75
75
|
code = encode_with_encoding code, self.encoding
|
76
76
|
else
|
@@ -100,7 +100,7 @@ module CodeRay
|
|
100
100
|
def encode_with_encoding code, target_encoding
|
101
101
|
if code.encoding == target_encoding
|
102
102
|
if code.valid_encoding?
|
103
|
-
return to_unix
|
103
|
+
return to_unix(code)
|
104
104
|
else
|
105
105
|
source_encoding = guess_encoding code
|
106
106
|
end
|
@@ -155,7 +155,7 @@ module CodeRay
|
|
155
155
|
setup
|
156
156
|
end
|
157
157
|
|
158
|
-
# Sets back the scanner. Subclasses should
|
158
|
+
# Sets back the scanner. Subclasses should redefine the reset_instance
|
159
159
|
# method instead of this one.
|
160
160
|
def reset
|
161
161
|
super
|
@@ -185,14 +185,12 @@ module CodeRay
|
|
185
185
|
@tokens = options[:tokens] || @tokens || Tokens.new
|
186
186
|
@tokens.scanner = self if @tokens.respond_to? :scanner=
|
187
187
|
case source
|
188
|
-
when String
|
189
|
-
self.string = source
|
190
188
|
when Array
|
191
|
-
self.string = source.join
|
189
|
+
self.string = self.class.normalize(source.join)
|
192
190
|
when nil
|
193
191
|
reset
|
194
192
|
else
|
195
|
-
|
193
|
+
self.string = self.class.normalize(source)
|
196
194
|
end
|
197
195
|
|
198
196
|
begin
|
data/lib/coderay/scanners/c.rb
CHANGED
data/lib/coderay/scanners/cpp.rb
CHANGED
@@ -33,11 +33,11 @@ module Scanners
|
|
33
33
|
'virtual', 'write', 'writeonly',
|
34
34
|
] # :nodoc:
|
35
35
|
|
36
|
-
IDENT_KIND =
|
36
|
+
IDENT_KIND = WordList::CaseIgnoring.new(:ident).
|
37
37
|
add(KEYWORDS, :keyword).
|
38
38
|
add(DIRECTIVES, :directive) # :nodoc:
|
39
39
|
|
40
|
-
NAME_FOLLOWS =
|
40
|
+
NAME_FOLLOWS = WordList::CaseIgnoring.new(false).
|
41
41
|
add(%w(procedure function .)) # :nodoc:
|
42
42
|
|
43
43
|
protected
|
@@ -50,7 +50,9 @@ module Scanners
|
|
50
50
|
if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/)
|
51
51
|
encoder.text_token match, :filename
|
52
52
|
if options[:highlight_code]
|
53
|
-
|
53
|
+
file_type = FileType.fetch(match, :text)
|
54
|
+
file_type = :text if file_type == :diff
|
55
|
+
content_scanner = scanners[file_type]
|
54
56
|
content_scanner_entry_state = nil
|
55
57
|
end
|
56
58
|
end
|
@@ -130,7 +130,7 @@ module Scanners
|
|
130
130
|
if match = scan(/0[xX][0-9A-Fa-f]+/)
|
131
131
|
encoder.text_token match, :hex
|
132
132
|
elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/)
|
133
|
-
encoder.text_token match, :
|
133
|
+
encoder.text_token match, :octal
|
134
134
|
elsif match = scan(/\d+[fFdD]|\d*\.\d+(?:[eE][+-]?\d+)?[fFdD]?|\d+[eE][+-]?\d+[fFdD]?/)
|
135
135
|
encoder.text_token match, :float
|
136
136
|
elsif match = scan(/\d+[lLgG]?/)
|
@@ -32,7 +32,7 @@ module Scanners
|
|
32
32
|
onvolumechange onwaiting
|
33
33
|
)
|
34
34
|
|
35
|
-
IN_ATTRIBUTE =
|
35
|
+
IN_ATTRIBUTE = WordList::CaseIgnoring.new(nil).
|
36
36
|
add(EVENT_ATTRIBUTES, :script)
|
37
37
|
|
38
38
|
ATTR_NAME = /[\w.:-]+/ # :nodoc:
|
@@ -58,10 +58,10 @@ module Scanners
|
|
58
58
|
'"' => /[^&">\n]+/,
|
59
59
|
} # :nodoc:
|
60
60
|
|
61
|
-
def reset
|
62
|
-
# FIXME: why not overwrite reset_instance?
|
61
|
+
def reset
|
63
62
|
super
|
64
63
|
@state = :initial
|
64
|
+
@plain_string_content = nil
|
65
65
|
end
|
66
66
|
|
67
67
|
protected
|
@@ -81,11 +81,12 @@ module Scanners
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def scan_tokens encoder, options
|
84
|
-
|
85
84
|
state = @state
|
86
85
|
plain_string_content = @plain_string_content
|
87
86
|
in_tag = in_attribute = nil
|
88
87
|
|
88
|
+
encoder.begin_group :string if state == :attribute_value_string
|
89
|
+
|
89
90
|
until eos?
|
90
91
|
|
91
92
|
if state != :in_special_tag && match = scan(/\s+/m)
|
@@ -239,12 +240,10 @@ module Scanners
|
|
239
240
|
if options[:keep_state]
|
240
241
|
@state = state
|
241
242
|
@plain_string_content = plain_string_content
|
242
|
-
else
|
243
|
-
if state == :attribute_value_string
|
244
|
-
encoder.end_group :string
|
245
|
-
end
|
246
243
|
end
|
247
244
|
|
245
|
+
encoder.end_group :string if state == :attribute_value_string
|
246
|
+
|
248
247
|
encoder
|
249
248
|
end
|
250
249
|
|
@@ -107,7 +107,7 @@ module Scanners
|
|
107
107
|
if match = scan(/0[xX][0-9A-Fa-f]+/)
|
108
108
|
encoder.text_token match, :hex
|
109
109
|
elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/)
|
110
|
-
encoder.text_token match, :
|
110
|
+
encoder.text_token match, :octal
|
111
111
|
elsif match = scan(/\d+[fFdD]|\d*\.\d+(?:[eE][+-]?\d+)?[fFdD]?|\d+[eE][+-]?\d+[fFdD]?/)
|
112
112
|
encoder.text_token match, :float
|
113
113
|
elsif match = scan(/\d+[lL]?/)
|
@@ -81,7 +81,7 @@ module Scanners
|
|
81
81
|
if match = scan(/0[xX][0-9A-Fa-f]+/)
|
82
82
|
encoder.text_token match, :hex
|
83
83
|
elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/)
|
84
|
-
encoder.text_token match, :
|
84
|
+
encoder.text_token match, :octal
|
85
85
|
elsif match = scan(/\d+[fF]|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
|
86
86
|
encoder.text_token match, :float
|
87
87
|
elsif match = scan(/\d+/)
|
data/lib/coderay/scanners/php.rb
CHANGED
@@ -194,7 +194,7 @@ module Scanners
|
|
194
194
|
encoder.text_token match, :hex
|
195
195
|
|
196
196
|
elsif match = scan(/0[bB][01]+[lL]?/)
|
197
|
-
encoder.text_token match, :
|
197
|
+
encoder.text_token match, :binary
|
198
198
|
|
199
199
|
elsif match = scan(/(?:\d*\.\d+|\d+\.\d*)(?:[eE][+-]?\d+)?|\d+[eE][+-]?\d+/)
|
200
200
|
if scan(/[jJ]/)
|
@@ -205,7 +205,7 @@ module Scanners
|
|
205
205
|
end
|
206
206
|
|
207
207
|
elsif match = scan(/0[oO][0-7]+|0[0-7]+(?![89.eE])[lL]?/)
|
208
|
-
encoder.text_token match, :
|
208
|
+
encoder.text_token match, :octal
|
209
209
|
|
210
210
|
elsif match = scan(/\d+([lL])?/)
|
211
211
|
if self[1] == nil && scan(/[jJ]/)
|
@@ -178,7 +178,7 @@ module Scanners
|
|
178
178
|
encoder.text_token match, :error
|
179
179
|
method_call_expected = false
|
180
180
|
else
|
181
|
-
encoder.text_token match, self[1] ? :float : :integer
|
181
|
+
encoder.text_token match, self[1] ? :float : :integer # TODO: send :hex/:octal/:binary
|
182
182
|
end
|
183
183
|
value_expected = false
|
184
184
|
|
data/lib/coderay/scanners/sql.rb
CHANGED
@@ -42,7 +42,7 @@ module CodeRay module Scanners
|
|
42
42
|
|
43
43
|
PREDEFINED_CONSTANTS = %w( null true false )
|
44
44
|
|
45
|
-
IDENT_KIND =
|
45
|
+
IDENT_KIND = WordList::CaseIgnoring.new(:ident).
|
46
46
|
add(KEYWORDS, :keyword).
|
47
47
|
add(OBJECTS, :type).
|
48
48
|
add(COMMANDS, :class).
|
@@ -97,7 +97,7 @@ module CodeRay module Scanners
|
|
97
97
|
encoder.text_token match, :hex
|
98
98
|
|
99
99
|
elsif match = scan(/0[0-7]+(?![89.eEfF])/)
|
100
|
-
encoder.text_token match, :
|
100
|
+
encoder.text_token match, :octal
|
101
101
|
|
102
102
|
elsif match = scan(/[-+]?(?>\d+)(?![.eEfF])/)
|
103
103
|
encoder.text_token match, :integer
|
@@ -108,10 +108,10 @@ module Scanners
|
|
108
108
|
encoder.text_token match, :class_variable
|
109
109
|
next
|
110
110
|
when match = scan(/\d\d:\d\d:\d\d/)
|
111
|
-
encoder.text_token match, :
|
111
|
+
encoder.text_token match, :octal
|
112
112
|
next
|
113
113
|
when match = scan(/\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d(\.\d+)? [-+]\d\d:\d\d/)
|
114
|
-
encoder.text_token match, :
|
114
|
+
encoder.text_token match, :octal
|
115
115
|
next
|
116
116
|
when match = scan(/:\w+/)
|
117
117
|
encoder.text_token match, :symbol
|
data/lib/coderay/styles/alpha.rb
CHANGED
@@ -26,7 +26,7 @@ span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
|
26
26
|
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
27
27
|
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
28
28
|
|
29
|
-
.CodeRay .
|
29
|
+
.CodeRay .line-numbers {
|
30
30
|
background-color: #{numbers_background};
|
31
31
|
color: gray;
|
32
32
|
text-align: right;
|
@@ -34,15 +34,15 @@ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
|
34
34
|
-moz-user-select: none;
|
35
35
|
user-select: none;
|
36
36
|
}
|
37
|
-
.CodeRay .
|
37
|
+
.CodeRay .line-numbers a {
|
38
38
|
background-color: #{numbers_background} !important;
|
39
39
|
color: gray !important;
|
40
40
|
text-decoration: none !important;
|
41
41
|
}
|
42
|
-
.CodeRay .
|
43
|
-
.CodeRay .
|
44
|
-
.CodeRay .
|
45
|
-
.CodeRay .
|
42
|
+
.CodeRay .line-numbers a:target { color: blue !important; }
|
43
|
+
.CodeRay .line-numbers .highlighted { color: red !important; }
|
44
|
+
.CodeRay .line-numbers .highlighted a { color: red !important; }
|
45
|
+
.CodeRay span.line-numbers { padding: 0px 4px; }
|
46
46
|
.CodeRay .line { display: block; float: left; width: 100%; }
|
47
47
|
.CodeRay .code { width: 100%; }
|
48
48
|
.CodeRay .code pre { overflow: auto; }
|
@@ -51,102 +51,89 @@ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
|
51
51
|
TOKEN_COLORS = <<-'TOKENS'
|
52
52
|
.debug { color: white !important; background: blue !important; }
|
53
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
|
-
.
|
80
|
-
.
|
81
|
-
.
|
82
|
-
.
|
83
|
-
.
|
84
|
-
.
|
85
|
-
.
|
86
|
-
.
|
87
|
-
.
|
88
|
-
|
89
|
-
.
|
90
|
-
.
|
91
|
-
|
92
|
-
.
|
93
|
-
.
|
94
|
-
.
|
95
|
-
.
|
96
|
-
.
|
97
|
-
.
|
98
|
-
.
|
99
|
-
.
|
100
|
-
.
|
101
|
-
.
|
102
|
-
.
|
103
|
-
.
|
104
|
-
.
|
105
|
-
.
|
106
|
-
.
|
107
|
-
|
108
|
-
.
|
109
|
-
.
|
110
|
-
.
|
111
|
-
.
|
112
|
-
|
113
|
-
.
|
114
|
-
.
|
115
|
-
.
|
116
|
-
.
|
117
|
-
|
118
|
-
.
|
119
|
-
.
|
120
|
-
.
|
121
|
-
.
|
122
|
-
.
|
123
|
-
|
124
|
-
|
125
|
-
.
|
126
|
-
.
|
127
|
-
|
128
|
-
.sy { color:#A60 }
|
129
|
-
.sy .k { color:#A60 }
|
130
|
-
.sy .dl { color:#630 }
|
131
|
-
|
132
|
-
.ta { color:#070 }
|
133
|
-
.ts { color:#D70; font-weight:bold }
|
134
|
-
.ty { color:#339; font-weight:bold }
|
135
|
-
.v { color:#037 }
|
136
|
-
.xt { color:#444 }
|
137
|
-
|
138
|
-
.ins { background: hsla(120,100%,50%,0.1) }
|
139
|
-
.del { background: hsla(0,100%,50%,0.1) }
|
140
|
-
.chg { color: #bbf; background: #007; }
|
54
|
+
.annotation { color:#007 }
|
55
|
+
.attribute-name { color:#f08 }
|
56
|
+
.attribute-value { color:#700 }
|
57
|
+
.binary { color:#509 }
|
58
|
+
.char .content { color:#D20 }
|
59
|
+
.char .delimiter { color:#710 }
|
60
|
+
.char { color:#D20 }
|
61
|
+
.class { color:#B06; font-weight:bold }
|
62
|
+
.class-variable { color:#369 }
|
63
|
+
.color { color:#0A0 }
|
64
|
+
.comment { color:#888 }
|
65
|
+
.comment .char { color:#444 }
|
66
|
+
.comment .delimiter { color:#444 }
|
67
|
+
.complex { color:#A08 }
|
68
|
+
.constant { color:#036; font-weight:bold }
|
69
|
+
.decorator { color:#B0B }
|
70
|
+
.definition { color:#099; font-weight:bold }
|
71
|
+
.delimiter { color:black }
|
72
|
+
.directive { color:#088; font-weight:bold }
|
73
|
+
.doc { color:#970 }
|
74
|
+
.doc-string { color:#D42; font-weight:bold }
|
75
|
+
.doctype { color:#34b }
|
76
|
+
.entity { color:#800; font-weight:bold }
|
77
|
+
.error { color:#F00; background-color:#FAA }
|
78
|
+
.escape { color:#666 }
|
79
|
+
.exception { color:#C00; font-weight:bold }
|
80
|
+
.float { color:#60E }
|
81
|
+
.function { color:#06B; font-weight:bold }
|
82
|
+
.global-variable { color:#d70 }
|
83
|
+
.hex { color:#02b }
|
84
|
+
.imaginary { color:#f00 }
|
85
|
+
.include { color:#B44; font-weight:bold }
|
86
|
+
.inline { background-color: hsla(0,0%,0%,0.1); color: black }
|
87
|
+
.inline-delimiter { font-weight: bold; color: #666 }
|
88
|
+
.instance-variable { color:#33B }
|
89
|
+
.integer { color:#00D }
|
90
|
+
.key .char { color: #60f }
|
91
|
+
.key .delimiter { color: #404 }
|
92
|
+
.key { color: #606 }
|
93
|
+
.keyword { color:#080; font-weight:bold }
|
94
|
+
.label { color:#970; font-weight:bold }
|
95
|
+
.local-variable { color:#963 }
|
96
|
+
.namespace { color:#707; font-weight:bold }
|
97
|
+
.octal { color:#40E }
|
98
|
+
.operator { }
|
99
|
+
.predefined { color:#369; font-weight:bold }
|
100
|
+
.predefined-class { color:#069 }
|
101
|
+
.predefined-type { color:#0a5; font-weight:bold }
|
102
|
+
.preprocessor { color:#579 }
|
103
|
+
.pseudo-class { color:#00C; font-weight:bold }
|
104
|
+
.regexp .content { color:#808 }
|
105
|
+
.regexp .delimiter { color:#404 }
|
106
|
+
.regexp .modifier { color:#C2C }
|
107
|
+
.regexp { background-color:hsla(300,100%,50%,0.09); }
|
108
|
+
.reserved { color:#080; font-weight:bold }
|
109
|
+
.shell .content { color:#2B2 }
|
110
|
+
.shell .delimiter { color:#161 }
|
111
|
+
.shell { background-color:hsla(120,100%,50%,0.09); }
|
112
|
+
.string .char { color: #b0b }
|
113
|
+
.string .content { color: #D20 }
|
114
|
+
.string .delimiter { color: #710 }
|
115
|
+
.string .modifier { color: #E40 }
|
116
|
+
.string { background-color:hsla(0,100%,50%,0.08); }
|
117
|
+
.symbol .content { color:#A60 }
|
118
|
+
.symbol .delimiter { color:#630 }
|
119
|
+
.symbol { color:#A60 }
|
120
|
+
.tag { color:#070 }
|
121
|
+
.type { color:#339; font-weight:bold }
|
122
|
+
.value { color: #088; }
|
123
|
+
.variable { color:#037 }
|
124
|
+
|
125
|
+
.insert { background: hsla(120,100%,50%,0.1) }
|
126
|
+
.delete { background: hsla(0,100%,50%,0.1) }
|
127
|
+
.change { color: #bbf; background: #007; }
|
141
128
|
.head { color: #f8f; background: #505 }
|
142
129
|
.head .filename { color: white; }
|
143
130
|
|
144
|
-
.
|
145
|
-
.
|
131
|
+
.delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; }
|
132
|
+
.insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }
|
146
133
|
|
147
|
-
.
|
148
|
-
.
|
149
|
-
.
|
134
|
+
.insert .insert { color: #0c0; background:transparent; font-weight:bold }
|
135
|
+
.delete .delete { color: #c00; background:transparent; font-weight:bold }
|
136
|
+
.change .change { color: #88f }
|
150
137
|
.head .head { color: #f4f }
|
151
138
|
TOKENS
|
152
139
|
|
data/lib/coderay/token_kinds.rb
CHANGED
@@ -10,77 +10,76 @@ module CodeRay
|
|
10
10
|
TokenKinds.compare_by_identity if TokenKinds.respond_to? :compare_by_identity
|
11
11
|
|
12
12
|
TokenKinds.update( # :nodoc:
|
13
|
-
:annotation
|
14
|
-
:attribute_name
|
15
|
-
:attribute_value
|
16
|
-
:
|
17
|
-
:char
|
18
|
-
:class
|
19
|
-
:class_variable
|
20
|
-
:color
|
21
|
-
:comment
|
22
|
-
:complex
|
23
|
-
:constant
|
24
|
-
:content
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:key
|
50
|
-
:keyword
|
51
|
-
:label
|
52
|
-
:local_variable
|
53
|
-
:modifier
|
54
|
-
:namespace
|
55
|
-
:
|
56
|
-
:predefined
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:pseudo_class
|
61
|
-
:regexp
|
62
|
-
:reserved
|
63
|
-
:shell
|
64
|
-
:string
|
65
|
-
:symbol
|
66
|
-
:tag
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:variable => 'v',
|
13
|
+
:annotation => 'annotation',
|
14
|
+
:attribute_name => 'attribute-name',
|
15
|
+
:attribute_value => 'attribute-value',
|
16
|
+
:binary => 'bin',
|
17
|
+
:char => 'char',
|
18
|
+
:class => 'class',
|
19
|
+
:class_variable => 'class-variable',
|
20
|
+
:color => 'color',
|
21
|
+
:comment => 'comment',
|
22
|
+
:complex => 'complex',
|
23
|
+
:constant => 'constant',
|
24
|
+
:content => 'content',
|
25
|
+
:debug => 'debug',
|
26
|
+
:decorator => 'decorator',
|
27
|
+
:definition => 'definition',
|
28
|
+
:delimiter => 'delimiter',
|
29
|
+
:directive => 'directive',
|
30
|
+
:doc => 'doc',
|
31
|
+
:doctype => 'doctype',
|
32
|
+
:doc_string => 'doc-string',
|
33
|
+
:entity => 'entity',
|
34
|
+
:error => 'error',
|
35
|
+
:escape => 'escape',
|
36
|
+
:exception => 'exception',
|
37
|
+
:filename => 'filename',
|
38
|
+
:float => 'float',
|
39
|
+
:function => 'function',
|
40
|
+
:global_variable => 'global-variable',
|
41
|
+
:hex => 'hex',
|
42
|
+
:imaginary => 'imaginary',
|
43
|
+
:important => 'important',
|
44
|
+
:include => 'include',
|
45
|
+
:inline => 'inline',
|
46
|
+
:inline_delimiter => 'inline-delimiter',
|
47
|
+
:instance_variable => 'instance-variable',
|
48
|
+
:integer => 'integer',
|
49
|
+
:key => 'key',
|
50
|
+
:keyword => 'keyword',
|
51
|
+
:label => 'label',
|
52
|
+
:local_variable => 'local-variable',
|
53
|
+
:modifier => 'modifier',
|
54
|
+
:namespace => 'namespace',
|
55
|
+
:octal => 'octal',
|
56
|
+
:predefined => 'predefined',
|
57
|
+
:predefined_constant => 'predefined-constant',
|
58
|
+
:predefined_type => 'predefined-type',
|
59
|
+
:preprocessor => 'preprocessor',
|
60
|
+
:pseudo_class => 'pseudo-class',
|
61
|
+
:regexp => 'regexp',
|
62
|
+
:reserved => 'reserved',
|
63
|
+
:shell => 'shell',
|
64
|
+
:string => 'string',
|
65
|
+
:symbol => 'symbol',
|
66
|
+
:tag => 'tag',
|
67
|
+
:type => 'type',
|
68
|
+
:value => 'value',
|
69
|
+
:variable => 'variable',
|
71
70
|
|
72
|
-
:
|
73
|
-
:delete
|
74
|
-
:
|
75
|
-
:
|
71
|
+
:change => 'change',
|
72
|
+
:delete => 'delete',
|
73
|
+
:head => 'head',
|
74
|
+
:insert => 'insert',
|
76
75
|
|
77
|
-
:eyecatcher
|
76
|
+
:eyecatcher => 'eyecatcher',
|
78
77
|
|
79
|
-
:ident
|
80
|
-
:operator
|
78
|
+
:ident => false,
|
79
|
+
:operator => false,
|
81
80
|
|
82
|
-
:space
|
83
|
-
:plain
|
81
|
+
:space => false,
|
82
|
+
:plain => false
|
84
83
|
)
|
85
84
|
|
86
85
|
TokenKinds[:method] = TokenKinds[:function]
|
data/test/functional/basic.rb
CHANGED
@@ -30,8 +30,8 @@ class BasicTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
RUBY_TEST_HTML = 'puts <span class="
|
34
|
-
'<span class="
|
33
|
+
RUBY_TEST_HTML = 'puts <span class="string"><span class="delimiter">"</span>' +
|
34
|
+
'<span class="content">Hello, World!</span><span class="delimiter">"</span></span>'
|
35
35
|
def test_simple_highlight
|
36
36
|
assert_nothing_raised do
|
37
37
|
assert_equal RUBY_TEST_HTML, CodeRay.scan(RUBY_TEST_CODE, :ruby).html
|
@@ -59,7 +59,7 @@ class BasicTest < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_highlight_file
|
62
|
-
assert_match "require <span class=\"
|
62
|
+
assert_match "require <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">test/unit</span><span class=\"delimiter\">'</span></span>\n", CodeRay.highlight_file(__FILE__)
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_duo
|
@@ -147,7 +147,7 @@ more code # and another comment, in-line.
|
|
147
147
|
assert_kind_of String, css_class, "TokenKinds[%p] == %p" % [kind, css_class]
|
148
148
|
end
|
149
149
|
end
|
150
|
-
assert_equal '
|
150
|
+
assert_equal 'reserved', CodeRay::TokenKinds[:reserved]
|
151
151
|
assert_equal false, CodeRay::TokenKinds[:shibboleet]
|
152
152
|
end
|
153
153
|
|
@@ -213,9 +213,7 @@ more code # and another comment, in-line.
|
|
213
213
|
def test_scanner_tokenize
|
214
214
|
assert_equal ['foo', :plain], CodeRay::Scanners::Plain.new.tokenize('foo')
|
215
215
|
assert_equal [['foo', :plain], ['bar', :plain]], CodeRay::Scanners::Plain.new.tokenize(['foo', 'bar'])
|
216
|
-
|
217
|
-
CodeRay::Scanners::Plain.new.tokenize 42
|
218
|
-
end
|
216
|
+
CodeRay::Scanners::Plain.new.tokenize 42
|
219
217
|
end
|
220
218
|
|
221
219
|
def test_scanner_tokens
|
data/test/functional/examples.rb
CHANGED
@@ -22,7 +22,7 @@ end
|
|
22
22
|
CODE
|
23
23
|
assert_equal <<-DIV, div
|
24
24
|
<table class="CodeRay"><tr>
|
25
|
-
<td class="
|
25
|
+
<td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><a href="#n1" name="n1">1</a>
|
26
26
|
<a href="#n2" name="n2">2</a>
|
27
27
|
<a href="#n3" name="n3">3</a>
|
28
28
|
</pre></td>
|
@@ -38,9 +38,9 @@ end
|
|
38
38
|
<body style="background-color: white;">
|
39
39
|
|
40
40
|
<table class="CodeRay"><tr>
|
41
|
-
<td class="
|
41
|
+
<td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>
|
42
42
|
</pre></td>
|
43
|
-
<td class="code"><pre>puts <span class="
|
43
|
+
<td class="code"><pre>puts <span class="string"><span class="delimiter">"</span><span class="content">Hello, world!</span><span class="delimiter">"</span></span></pre></td>
|
44
44
|
</tr></table>
|
45
45
|
|
46
46
|
</body>
|
@@ -90,7 +90,7 @@ Token Types (7):
|
|
90
90
|
div = tokens.div(:css => :class)
|
91
91
|
assert_equal <<-DIV, div
|
92
92
|
<div class="CodeRay">
|
93
|
-
<div class="code"><pre>{ <span class="
|
93
|
+
<div class="code"><pre>{ <span class="key"><span class="delimiter">"</span><span class="content">just</span><span class="delimiter">"</span></span>: <span class="string"><span class="delimiter">"</span><span class="content">an</span><span class="delimiter">"</span></span>, <span class="key"><span class="delimiter">"</span><span class="content">example</span><span class="delimiter">"</span></span>: <span class="integer">42</span> }</pre></div>
|
94
94
|
</div>
|
95
95
|
DIV
|
96
96
|
|
metadata
CHANGED
@@ -1,36 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: coderay
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.831pre
|
5
5
|
prerelease: 9
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
- 815
|
11
|
-
- pre
|
12
|
-
version: 1.0.0.815pre
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- Kornelius Kalnbach
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
date: 2011-08-19 00:00:00 +02:00
|
21
|
-
default_executable:
|
12
|
+
date: 2011-08-23 00:00:00.000000000Z
|
22
13
|
dependencies: []
|
23
|
-
|
24
|
-
|
25
|
-
email:
|
14
|
+
description: Fast and easy syntax highlighting for selected languages, written in
|
15
|
+
Ruby. Comes with RedCloth integration and LOC counter.
|
16
|
+
email:
|
26
17
|
- murphy@rubychan.de
|
27
|
-
executables:
|
18
|
+
executables:
|
28
19
|
- coderay
|
29
20
|
extensions: []
|
30
|
-
|
31
|
-
extra_rdoc_files:
|
21
|
+
extra_rdoc_files:
|
32
22
|
- README_INDEX.rdoc
|
33
|
-
files:
|
23
|
+
files:
|
34
24
|
- lib/coderay/duo.rb
|
35
25
|
- lib/coderay/encoder.rb
|
36
26
|
- lib/coderay/encoders/_map.rb
|
@@ -88,8 +78,6 @@ files:
|
|
88
78
|
- lib/coderay/style.rb
|
89
79
|
- lib/coderay/styles/_map.rb
|
90
80
|
- lib/coderay/styles/alpha.rb
|
91
|
-
- lib/coderay/styles/cycnus.rb
|
92
|
-
- lib/coderay/styles/murphy.rb
|
93
81
|
- lib/coderay/token_kinds.rb
|
94
82
|
- lib/coderay/tokens.rb
|
95
83
|
- lib/coderay/version.rb
|
@@ -102,47 +90,34 @@ files:
|
|
102
90
|
- test/functional/for_redcloth.rb
|
103
91
|
- test/functional/suite.rb
|
104
92
|
- bin/coderay
|
105
|
-
has_rdoc: true
|
106
93
|
homepage: http://coderay.rubychan.de
|
107
94
|
licenses: []
|
108
|
-
|
109
95
|
post_install_message:
|
110
|
-
rdoc_options:
|
96
|
+
rdoc_options:
|
111
97
|
- -SNw2
|
112
98
|
- -mREADME_INDEX.rdoc
|
113
99
|
- -t CodeRay Documentation
|
114
|
-
require_paths:
|
100
|
+
require_paths:
|
115
101
|
- lib
|
116
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
103
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
hash: 57
|
122
|
-
segments:
|
123
|
-
- 1
|
124
|
-
- 8
|
125
|
-
- 7
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
126
107
|
version: 1.8.7
|
127
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
109
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
hash: 25
|
133
|
-
segments:
|
134
|
-
- 1
|
135
|
-
- 3
|
136
|
-
- 1
|
110
|
+
requirements:
|
111
|
+
- - ! '>'
|
112
|
+
- !ruby/object:Gem::Version
|
137
113
|
version: 1.3.1
|
138
114
|
requirements: []
|
139
|
-
|
140
115
|
rubyforge_project: coderay
|
141
|
-
rubygems_version: 1.
|
116
|
+
rubygems_version: 1.8.8
|
142
117
|
signing_key:
|
143
118
|
specification_version: 3
|
144
119
|
summary: Fast syntax highlighting for selected languages.
|
145
|
-
test_files:
|
120
|
+
test_files:
|
146
121
|
- test/functional/basic.rb
|
147
122
|
- test/functional/examples.rb
|
148
123
|
- test/functional/for_redcloth.rb
|
@@ -1,144 +0,0 @@
|
|
1
|
-
module CodeRay
|
2
|
-
module Styles
|
3
|
-
|
4
|
-
# A colorful theme that is also the default for CodeRay output.
|
5
|
-
class Cycnus < Style
|
6
|
-
|
7
|
-
register_for :cycnus
|
8
|
-
|
9
|
-
code_background = '#f8f8f8'
|
10
|
-
numbers_background = '#def'
|
11
|
-
border_color = 'silver'
|
12
|
-
normal_color = '#000'
|
13
|
-
|
14
|
-
CSS_MAIN_STYLES = <<-MAIN # :nodoc:
|
15
|
-
.CodeRay {
|
16
|
-
background-color: #{code_background};
|
17
|
-
border: 1px solid #{border_color};
|
18
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
19
|
-
color: #{normal_color};
|
20
|
-
}
|
21
|
-
.CodeRay pre { margin: 0px; }
|
22
|
-
|
23
|
-
span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
24
|
-
|
25
|
-
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
26
|
-
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
27
|
-
|
28
|
-
.CodeRay .line_numbers, .CodeRay .no {
|
29
|
-
background-color: #{numbers_background};
|
30
|
-
color: gray;
|
31
|
-
text-align: right;
|
32
|
-
}
|
33
|
-
.CodeRay .line_numbers .highlighted, .CodeRay .no .highlighted { color: red; }
|
34
|
-
.CodeRay .no { padding: 0px 4px; }
|
35
|
-
.CodeRay .line { display: block; float: left; width: 100%; }
|
36
|
-
.CodeRay .code { width: 100%; }
|
37
|
-
.CodeRay .code pre { overflow: auto; }
|
38
|
-
MAIN
|
39
|
-
|
40
|
-
TOKEN_COLORS = <<-'TOKENS'
|
41
|
-
.debug { color: white !important; background: blue !important; }
|
42
|
-
|
43
|
-
.an { color:#007 }
|
44
|
-
.at { color:#f08 }
|
45
|
-
.av { color:#700 }
|
46
|
-
.bi { color:#509; font-weight:bold }
|
47
|
-
.c { color:#888; }
|
48
|
-
|
49
|
-
.ch { color:#04D }
|
50
|
-
.ch .k { color:#04D }
|
51
|
-
.ch .dl { color:#039 }
|
52
|
-
|
53
|
-
.cl { color:#B06; font-weight:bold }
|
54
|
-
.cm { color:#A08; font-weight:bold }
|
55
|
-
.co { color:#036; font-weight:bold }
|
56
|
-
.cr { color:#0A0 }
|
57
|
-
.cv { color:#369 }
|
58
|
-
.de { color:#B0B; }
|
59
|
-
.df { color:#099; font-weight:bold }
|
60
|
-
.di { color:#088; font-weight:bold }
|
61
|
-
.dl { color:black }
|
62
|
-
.do { color:#970 }
|
63
|
-
.dt { color:#34b }
|
64
|
-
.ds { color:#D42; font-weight:bold }
|
65
|
-
.e { color:#666; font-weight:bold }
|
66
|
-
.en { color:#800; font-weight:bold }
|
67
|
-
.er { color:#F00; background-color:#FAA }
|
68
|
-
.ex { color:#C00; font-weight:bold }
|
69
|
-
.fl { color:#60E; font-weight:bold }
|
70
|
-
.fu { color:#06B; font-weight:bold }
|
71
|
-
.gv { color:#d70; font-weight:bold }
|
72
|
-
.hx { color:#058; font-weight:bold }
|
73
|
-
.i { color:#00D; font-weight:bold }
|
74
|
-
.ic { color:#B44; font-weight:bold }
|
75
|
-
|
76
|
-
.il { background: #ddd; color: black }
|
77
|
-
.il .il { background: #ccc }
|
78
|
-
.il .il .il { background: #bbb }
|
79
|
-
.il .idl { background: #ddd; font-weight: bold; color: #666 }
|
80
|
-
.idl { background-color: #bbb; font-weight: bold; color: #666; }
|
81
|
-
|
82
|
-
.im { color:#f00; }
|
83
|
-
.in { color:#B2B; font-weight:bold }
|
84
|
-
.iv { color:#33B }
|
85
|
-
.la { color:#970; font-weight:bold }
|
86
|
-
.lv { color:#963 }
|
87
|
-
.ns { color:#707; font-weight:bold }
|
88
|
-
.oc { color:#40E; font-weight:bold }
|
89
|
-
.op { }
|
90
|
-
.pc { color:#058; font-weight:bold }
|
91
|
-
.pd { color:#369; font-weight:bold }
|
92
|
-
.pp { color:#579; }
|
93
|
-
.ps { color:#00C; font-weight:bold }
|
94
|
-
.pt { color:#074; font-weight:bold }
|
95
|
-
.r, .kw { color:#080; font-weight:bold }
|
96
|
-
|
97
|
-
.ke { color: #808; }
|
98
|
-
.ke .dl { color: #606; }
|
99
|
-
.ke .ch { color: #80f; }
|
100
|
-
.vl { color: #088; }
|
101
|
-
|
102
|
-
.rx { background-color:#fff0ff; color:#808 }
|
103
|
-
.rx .k { }
|
104
|
-
.rx .dl { color:#404 }
|
105
|
-
.rx .mod { color:#C2C }
|
106
|
-
.rx .fu { color:#404; font-weight: bold }
|
107
|
-
|
108
|
-
.s { background-color:#fff0f0; color: #D20; }
|
109
|
-
.s .s { background-color:#ffe0e0 }
|
110
|
-
.s .s .s { background-color:#ffd0d0 }
|
111
|
-
.s .k { }
|
112
|
-
.s .ch { color: #b0b; }
|
113
|
-
.s .dl { color: #710; }
|
114
|
-
|
115
|
-
.sh { background-color:#f0fff0; color:#2B2 }
|
116
|
-
.sh .k { }
|
117
|
-
.sh .dl { color:#161 }
|
118
|
-
|
119
|
-
.sy { color:#A60 }
|
120
|
-
.sy .k { color:#A60 }
|
121
|
-
.sy .dl { color:#630 }
|
122
|
-
|
123
|
-
.ta { color:#070 }
|
124
|
-
.ts { color:#D70; font-weight:bold }
|
125
|
-
.ty { color:#339; font-weight:bold }
|
126
|
-
.v { color:#036 }
|
127
|
-
.xt { color:#444 }
|
128
|
-
|
129
|
-
.ins { background: #afa; }
|
130
|
-
.del { background: #faa; }
|
131
|
-
.chg { color: #aaf; background: #007; }
|
132
|
-
.head { color: #f8f; background: #505 }
|
133
|
-
.head .filename { color: white; }
|
134
|
-
|
135
|
-
.ins .ins { color: #080; font-weight:bold }
|
136
|
-
.del .del { color: #800; font-weight:bold }
|
137
|
-
.chg .chg { color: #66f; }
|
138
|
-
.head .head { color: #f4f; }
|
139
|
-
TOKENS
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
module CodeRay
|
2
|
-
module Styles
|
3
|
-
|
4
|
-
# A alternative color theme.
|
5
|
-
class Murphy < Style
|
6
|
-
|
7
|
-
register_for :murphy
|
8
|
-
|
9
|
-
code_background = '#001129'
|
10
|
-
numbers_background = code_background
|
11
|
-
border_color = 'silver'
|
12
|
-
normal_color = '#C0C0C0'
|
13
|
-
|
14
|
-
CSS_MAIN_STYLES = <<-MAIN # :nodoc:
|
15
|
-
.CodeRay {
|
16
|
-
background-color: #{code_background};
|
17
|
-
border: 1px solid #{border_color};
|
18
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
19
|
-
color: #{normal_color};
|
20
|
-
}
|
21
|
-
.CodeRay pre { margin: 0px; }
|
22
|
-
|
23
|
-
span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
24
|
-
|
25
|
-
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
26
|
-
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
27
|
-
|
28
|
-
.CodeRay .line_numbers, .CodeRay .no {
|
29
|
-
background-color: #{numbers_background};
|
30
|
-
color: gray;
|
31
|
-
text-align: right;
|
32
|
-
}
|
33
|
-
.CodeRay .line_numbers .highlighted, .CodeRay .no .highlighted { color: red; }
|
34
|
-
.CodeRay .no { padding: 0px 4px; }
|
35
|
-
.CodeRay .code { width: 100%; }
|
36
|
-
.CodeRay .code pre { overflow: auto; }
|
37
|
-
MAIN
|
38
|
-
|
39
|
-
TOKEN_COLORS = <<-'TOKENS'
|
40
|
-
.an { color:#007; }
|
41
|
-
.av { color:#700; }
|
42
|
-
.bi { color:#509; font-weight:bold; }
|
43
|
-
.c { color:#555; background-color: black; }
|
44
|
-
|
45
|
-
.ch { color:#88F; }
|
46
|
-
.ch .k { color:#04D; }
|
47
|
-
.ch .dl { color:#039; }
|
48
|
-
|
49
|
-
.cl { color:#e9e; font-weight:bold; }
|
50
|
-
.co { color:#5ED; font-weight:bold; }
|
51
|
-
.cr { color:#0A0; }
|
52
|
-
.cv { color:#ccf; }
|
53
|
-
.df { color:#099; font-weight:bold; }
|
54
|
-
.di { color:#088; font-weight:bold; }
|
55
|
-
.dl { color:black; }
|
56
|
-
.do { color:#970; }
|
57
|
-
.ds { color:#D42; font-weight:bold; }
|
58
|
-
.e { color:#666; font-weight:bold; }
|
59
|
-
.er { color:#F00; background-color:#FAA; }
|
60
|
-
.ex { color:#F00; font-weight:bold; }
|
61
|
-
.fl { color:#60E; font-weight:bold; }
|
62
|
-
.fu { color:#5ed; font-weight:bold; }
|
63
|
-
.gv { color:#f84; }
|
64
|
-
.hx { color:#058; font-weight:bold; }
|
65
|
-
.i { color:#66f; font-weight:bold; }
|
66
|
-
.ic { color:#B44; font-weight:bold; }
|
67
|
-
.il { }
|
68
|
-
.in { color:#B2B; font-weight:bold; }
|
69
|
-
.iv { color:#aaf; }
|
70
|
-
.la { color:#970; font-weight:bold; }
|
71
|
-
.lv { color:#963; }
|
72
|
-
.oc { color:#40E; font-weight:bold; }
|
73
|
-
.op { }
|
74
|
-
.pc { color:#08f; font-weight:bold; }
|
75
|
-
.pd { color:#369; font-weight:bold; }
|
76
|
-
.pp { color:#579; }
|
77
|
-
.pt { color:#66f; font-weight:bold; }
|
78
|
-
.r { color:#5de; font-weight:bold; }
|
79
|
-
.r, .kw { color:#5de; font-weight:bold }
|
80
|
-
|
81
|
-
.ke { color: #808; }
|
82
|
-
|
83
|
-
.rx { background-color:#221133; }
|
84
|
-
.rx .k { color:#f8f; }
|
85
|
-
.rx .dl { color:#f0f; }
|
86
|
-
.rx .mod { color:#f0b; }
|
87
|
-
.rx .fu { color:#404; font-weight: bold; }
|
88
|
-
|
89
|
-
.s { background-color:#331122; }
|
90
|
-
.s .s { background-color:#ffe0e0; }
|
91
|
-
.s .s .s { background-color:#ffd0d0; }
|
92
|
-
.s .k { color:#F88; }
|
93
|
-
.s .dl { color:#f55; }
|
94
|
-
|
95
|
-
.sh { background-color:#f0fff0; }
|
96
|
-
.sh .k { color:#2B2; }
|
97
|
-
.sh .dl { color:#161; }
|
98
|
-
|
99
|
-
.sy { color:#Fc8; }
|
100
|
-
.sy .k { color:#Fc8; }
|
101
|
-
.sy .dl { color:#F84; }
|
102
|
-
|
103
|
-
.ta { color:#070; }
|
104
|
-
.ts { color:#D70; font-weight:bold; }
|
105
|
-
.ty { color:#339; font-weight:bold; }
|
106
|
-
.v { color:#036; }
|
107
|
-
.xt { color:#444; }
|
108
|
-
|
109
|
-
.ins { background: #afa; }
|
110
|
-
.del { background: #faa; }
|
111
|
-
.chg { color: #aaf; background: #007; }
|
112
|
-
.head { color: #f8f; background: #505 }
|
113
|
-
|
114
|
-
.ins .ins { color: #080; font-weight:bold }
|
115
|
-
.del .del { color: #800; font-weight:bold }
|
116
|
-
.chg .chg { color: #66f; }
|
117
|
-
.head .head { color: #f4f; }
|
118
|
-
TOKENS
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
end
|