coderay 0.7.2.176 → 0.7.4.196

Sign up to get free protection for your applications and to get access to all the features.
data/FOLDERS CHANGED
@@ -46,7 +46,7 @@ Some files to enhance Rake, including the Autumnal Rdoc template and some script
46
46
 
47
47
  == test - Tests
48
48
 
49
- Test for the scanners.
49
+ Tests for the scanners.
50
50
 
51
51
  Each language has its own subfolder and sub-suite.
52
52
 
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 168 2006-07-11 13:39:47Z murphy $
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 http://rubyforge.org/projects/rubylexer) and lots
77
- of very interesting mails traffic
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 coding CodeRay,
81
- but also gave me a wonderful target to reach for the Ruby scanner.
82
- * everyone who used CodeRay on http://www.rubyforen.de and http://www.infhu.de/mx
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 http://www.python-forum.de
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 & CSS, VIM, RUBY,
88
- pizza, microwaves, guitars, scouting, programming, anime, manga, coke and green ice tea.
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
 
@@ -1,6 +1,6 @@
1
1
  # = CodeRay Library
2
2
  #
3
- # $Id: coderay.rb 162 2006-07-11 06:03:43Z murphy $
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
- Version = '0.7.2'
136
+ VERSION = '0.7.4'
137
137
 
138
138
  require 'coderay/tokens'
139
139
  require 'coderay/scanner'
@@ -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.is_a? ::String
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 174 2006-10-15 09:08:50Z murphy $
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 all_plugin_names and load.
35
+ # Loads all plugins using list and load.
36
36
  def load_all
37
- for plugin in all_plugin_names
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 all_plugin_names
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
- fancy_allowed = regexp_allowed = true
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
- fancy_allowed = regexp_allowed = false
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
- fancy_allowed = regexp_allowed = true
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
- regexp_allowed = true
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
- regexp_allowed = true
147
+ value_expected = true
149
148
  else
150
- raise_inspect 'else-case _ reached, because case %p was not handled' % [matched[0].chr], tokens
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
- fancy_allowed = regexp_allowed = :set if patterns::REGEXP_ALLOWED[match] or check(/\s+(?:%\S|\/\S)/)
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 (not last_token_dot and match = scan(/ ==?=? | \.\.?\.? | [\(\)\[\]\{\}] | :: | , /x)) or
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
- regexp_allowed = fancy_allowed = :set
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 regexp_allowed and match = scan(/\//)
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
- regexp_allowed = fancy_allowed = :set
229
+ value_expected = :set
226
230
  kind = :operator
227
231
 
228
- elsif fancy_allowed and match = scan(/#{patterns::HEREDOC_OPEN}/o)
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 fancy_allowed and match = scan(/#{patterns::FANCY_START_SAVE}/o)
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 fancy_allowed and match = scan(/#{patterns::CHARACTER}/o)
252
+ elsif value_expected and match = scan(/#{patterns::CHARACTER}/o)
249
253
  kind = :integer
250
254
 
251
255
  elsif match = scan(/ [\/%]=? | <(?:<|=>?)? | [?:;] /x)
252
- regexp_allowed = fancy_allowed = :set
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
- regexp_allowed = regexp_allowed == :set
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! scan slice slice! split
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.2.176
7
- date: 2006-10-15 00:00:00 +02:00
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
- - lib
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
- - !ruby/object:Gem::Version
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
- - murphy
30
+ - murphy
35
31
  files:
36
- - "./lib/coderay.rb"
37
- - "./lib/coderay/tokens.rb"
38
- - "./lib/coderay/encoder.rb"
39
- - "./lib/coderay/style.rb"
40
- - "./lib/coderay/duo.rb"
41
- - "./lib/coderay/scanner.rb"
42
- - "./lib/coderay/encoders/tokens.rb"
43
- - "./lib/coderay/encoders/debug.rb"
44
- - "./lib/coderay/encoders/text.rb"
45
- - "./lib/coderay/encoders/page.rb"
46
- - "./lib/coderay/encoders/null.rb"
47
- - "./lib/coderay/encoders/yaml.rb"
48
- - "./lib/coderay/encoders/span.rb"
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
- - "./lib/coderay/encoders/html/classes.rb"
56
- - "./lib/coderay/encoders/html/css.rb"
57
- - "./lib/coderay/encoders/html/numerization.rb"
58
- - "./lib/coderay/encoders/html/output.rb"
59
- - "./lib/coderay/helpers/gzip_simple.rb"
60
- - "./lib/coderay/helpers/filetype.rb"
61
- - "./lib/coderay/helpers/word_list.rb"
62
- - "./lib/coderay/helpers/plugin.rb"
63
- - "./lib/coderay/scanners/c.rb"
64
- - "./lib/coderay/scanners/rhtml.rb"
65
- - "./lib/coderay/scanners/html.rb"
66
- - "./lib/coderay/scanners/plaintext.rb"
67
- - "./lib/coderay/scanners/_map.rb"
68
- - "./lib/coderay/scanners/delphi.rb"
69
- - "./lib/coderay/scanners/xml.rb"
70
- - "./lib/coderay/scanners/ruby.rb"
71
- - "./lib/coderay/scanners/nitro_xhtml.rb"
72
- - "./lib/coderay/scanners/ruby/patterns.rb"
73
- - "./lib/coderay/styles/cycnus.rb"
74
- - "./lib/coderay/styles/murphy.rb"
75
- - "./lib/coderay/styles/_map.rb"
76
- - "./demo/demo_tokens.rb"
77
- - "./demo/suite.rb"
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"
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
- - "-SNw2"
104
- - "-mREADME"
105
- - "-a"
106
- - "-t CodeRay Documentation"
78
+ - -SNw2
79
+ - -mREADME
80
+ - -a
81
+ - -t CodeRay Documentation
107
82
  extra_rdoc_files:
108
- - "./README"
109
- - "./FOLDERS"
83
+ - ./README
84
+ - ./FOLDERS
110
85
  executables:
111
- - coderay
112
- - coderay_stylesheet
86
+ - coderay
87
+ - coderay_stylesheet
113
88
  extensions: []
89
+
114
90
  requirements:
115
- - strscan
116
- dependencies: []
91
+ - strscan
92
+ dependencies: []
93
+
@@ -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