coderay 0.5.0.115 → 0.5.0.121

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -18,13 +18,13 @@ And with line numbers.
18
18
  * is what everybody should have on their website
19
19
  * solves all your problems and makes the girls run after you
20
20
 
21
- Version: 0.5.0 (2005.november.5)
21
+ Version: 0.5.0 (2006.march.16)
22
22
  Author:: murphy
23
23
  Idea:: licenser
24
24
  Website:: rd.cYcnus.de/coderay[http://rd.cYcnus.de/coderay]
25
- Copyright:: (c) 2005 by cYcnus
25
+ Copyright:: (c) 2006 by cYcnus
26
26
  License:: GNU LGPL; see LICENSE file in the main directory.
27
- Subversion:: $Id: README 111 2006-03-15 22:51:50Z murphy $
27
+ Subversion:: $Id: README 119 2006-03-16 00:43:02Z murphy $
28
28
 
29
29
  -----
30
30
 
@@ -22,7 +22,7 @@ class CodeRaySuite < TestCase
22
22
 
23
23
  def test_ALL
24
24
  dir do
25
- for input in Dir["demo_*.rb"] - ['demo_server.rb', 'demo_stream.rb']
25
+ for input in Dir["demo_*.rb"] - %w(demo_server.rb demo_stream.rb)
26
26
  puts "[ testing #{input}... ]"
27
27
  name = File.basename(input, ".rb")
28
28
  output = name + '.out'
@@ -1,6 +1,6 @@
1
1
  # = CodeRay Library
2
2
  #
3
- # $Id: coderay.rb 96 2005-11-13 06:24:54Z murphy $
3
+ # $Id: coderay.rb 120 2006-03-16 18:35:43Z murphy $
4
4
  #
5
5
  # CodeRay is a Ruby library for syntax highlighting.
6
6
  #
@@ -69,10 +69,10 @@
69
69
  # * Input and language are always sorted in this order: +code+, +lang+.
70
70
  # (This is in alphabetical order, if you need a mnemonic ;)
71
71
  #
72
- # You should be able to highlight everything you want just using this methods;
72
+ # You should be able to highlight everything you want just using these methods;
73
73
  # so there is no need to dive into CodeRay's deep class hierarchy.
74
74
  #
75
- # The exmaples in the demo/ directory demonstrate common cases using this interface.
75
+ # The examples in the demo directory demonstrate common cases using this interface.
76
76
  #
77
77
  # = Basic Access Ways
78
78
  #
@@ -84,7 +84,7 @@
84
84
  # Each Token knows about what type it is: string, comment, class name, etc.
85
85
  #
86
86
  # Each +lang+ (language) has its own Scanner; for example, <tt>:ruby</tt> code is
87
- # handled by CodeRay::Scanners::RubyScanner.
87
+ # handled by CodeRay::Scanners::Ruby.
88
88
  #
89
89
  # CodeRay.scan:: Scan a string in a given language into Tokens.
90
90
  # This is the most common method to use.
@@ -100,16 +100,17 @@ module Encoders
100
100
  '<' => '&lt;',
101
101
  }
102
102
 
103
- # This is to prevent illegal HTML.
103
+ # This was to prevent illegal HTML.
104
104
  # Strange chars should still be avoided in codes.
105
- evil_chars = Array(0x00...0x20) - [?n, ?t]
105
+ evil_chars = Array(0x00...0x20) - [?\n, ?\t, ?\s]
106
106
  evil_chars.each { |i| HTML_ESCAPE[i.chr] = ' ' }
107
- ansi_chars = Array(0x7f..0xff)
108
- ansi_chars.each { |i| HTML_ESCAPE[i.chr] = '&#%d;' % i }
107
+ #ansi_chars = Array(0x7f..0xff)
108
+ #ansi_chars.each { |i| HTML_ESCAPE[i.chr] = '&#%d;' % i }
109
109
  # \x9 (\t) and \xA (\n) not included
110
- HTML_ESCAPE_PATTERN = /[\t&"><\xB-\x1f\x7f-\xff\0-\x8]/
110
+ #HTML_ESCAPE_PATTERN = /[\t&"><\0-\x8\xB-\x1f\x7f-\xff]/
111
+ HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1f]/
111
112
 
112
- TOKEN_KIND_TO_INFO = Hash.new do |h, kind|
113
+ TOKEN_KIND_TO_INFO = Hash.new { |h, kind|
113
114
  h[kind] =
114
115
  case kind
115
116
  when :pre_constant
@@ -117,8 +118,11 @@ module Encoders
117
118
  else
118
119
  kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize }
119
120
  end
120
- end
121
+ }
121
122
 
123
+ # Generate a hint about the given +classes+ in a +hint+ style.
124
+ #
125
+ # +hint+ may be :info, :info_long or :debug.
122
126
  def self.token_path_to_hint hint, classes
123
127
  return '' unless hint
124
128
  title =
@@ -126,9 +130,9 @@ module Encoders
126
130
  when :info
127
131
  TOKEN_KIND_TO_INFO[classes.first]
128
132
  when :info_long
129
- classes.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/')
133
+ classes.reverse.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/')
130
134
  when :debug
131
- k.inspect
135
+ classes.inspect
132
136
  end
133
137
  " title=\"#{title}\""
134
138
  end
@@ -145,7 +149,7 @@ module Encoders
145
149
  @css = CSS.new options[:style]
146
150
 
147
151
  hint = options[:hint]
148
- if hint and not [:debug, :info].include? hint
152
+ if hint and not [:debug, :info, :info_long].include? hint
149
153
  raise ArgumentError, "Unknown value %p for :hint; expected :info, :debug, false or nil." % hint
150
154
  end
151
155
 
@@ -179,7 +183,9 @@ module Encoders
179
183
  if classes.first == :NO_HIGHLIGHT and not hint
180
184
  h[k] = false
181
185
  else
186
+ styles.shift if [:delimiter, :modifier, :content, :escape].include? styles.first
182
187
  title = HTML.token_path_to_hint hint, styles
188
+ classes.delete 'il'
183
189
  style = @css[*classes]
184
190
  h[k] =
185
191
  if style
@@ -161,12 +161,11 @@ module CodeRay
161
161
  # This can not be undone, but should yield the same output
162
162
  # in most Encoders. It basically makes the output smaller.
163
163
  #
164
- # Combined with dump, it saves space for the cost
165
- # calculating time.
164
+ # Combined with dump, it saves space for the cost of time.
166
165
  #
167
166
  # If the scanner is written carefully, this is not required -
168
- # for example, consecutive //-comment lines can already be
169
- # joined in one token by the Scanner.
167
+ # for example, consecutive //-comment lines could already be
168
+ # joined in one comment token by the Scanner.
170
169
  def optimize
171
170
  print ' Tokens#optimize: before: %d - ' % size if $DEBUG
172
171
  last_kind = last_text = nil
@@ -219,7 +218,7 @@ module CodeRay
219
218
  dump.extend Undumping
220
219
  end
221
220
 
222
- # The total size of the tokens;
221
+ # The total size of the tokens.
223
222
  # Should be equal to the input size before
224
223
  # scanning.
225
224
  def text_size
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: coderay
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0.115
6
+ version: 0.5.0.121
7
7
  date: 2006-03-16 00:00:00 +01:00
8
8
  summary: CodeRay is a fast syntax highlighter engine for many languages.
9
9
  require_paths: