coderay 0.8.303 → 0.8.312

Sign up to get free protection for your applications and to get access to all the features.
data/lib/README CHANGED
@@ -18,7 +18,7 @@ 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.8.2
21
+ Version: 0.8.3
22
22
  Author:: murphy (Kornelius Kalnbach)
23
23
  Contact:: murphy rubychan de
24
24
  Website:: coderay.rubychan.de[http://coderay.rubychan.de]
@@ -87,6 +87,7 @@ Please report errors in this documentation to <murphy rubychan de>.
87
87
  * Jonathan Younger for pointing out the licence confusion caused by wrong LICENSE file.
88
88
  * Jeremy Hinegardner for finding the shebang-on-empty-file bug in FileType.
89
89
  * Charles Oliver Nutter and Yehuda Katz for helping me benchmark CodeRay on JRuby.
90
+ * Andreas Neuhaus for pointing out a markup bug in coderay/for_redcloth.
90
91
  * The folks at redmine.org - thank you for using and fixing CodeRay!
91
92
  * matz and all Ruby gods and gurus
92
93
  * The inventors of: the computer, the internet, the true color display, HTML &
@@ -2,8 +2,6 @@ module CodeRay
2
2
 
3
3
  # = Duo
4
4
  #
5
- # $Id: scanner.rb 123 2006-03-21 14:46:34Z murphy $
6
- #
7
5
  # A Duo is a convenient way to use CodeRay. You just create a Duo,
8
6
  # giving it a lang (language of the input code) and a format (desired
9
7
  # output format), and call Duo#highlight with the code.
@@ -48,6 +48,7 @@ module CodeRay
48
48
  opts[:lang] ? '' : "<pre#{pba(opts)}>"
49
49
  end
50
50
  def bc_close(opts) # :nodoc:
51
+ opts = @in_bc
51
52
  @in_bc = nil
52
53
  opts[:lang] ? '' : "</pre>\n"
53
54
  end
@@ -2,8 +2,6 @@ module CodeRay
2
2
 
3
3
  # = PluginHost
4
4
  #
5
- # $Id: plugin.rb 272 2009-01-01 13:57:08Z murphy $
6
- #
7
5
  # A simple subclass plugin system.
8
6
  #
9
7
  # Example:
@@ -4,8 +4,6 @@ module CodeRay
4
4
 
5
5
  # = Scanners
6
6
  #
7
- # $Id: scanner.rb 270 2009-01-01 03:19:28Z murphy $
8
- #
9
7
  # This module holds the Scanner class and its subclasses.
10
8
  # For example, the Ruby scanner is named CodeRay::Scanners::Ruby
11
9
  # can be found in coderay/scanners/ruby.
@@ -76,7 +76,7 @@ module Scanners
76
76
  class_name_follows = false
77
77
  else
78
78
  import_clause = true if match == 'import'
79
- class_name_follows = true if match == 'class'
79
+ class_name_follows = true if match == 'class' || match == 'interface'
80
80
  end
81
81
 
82
82
  elsif scan(/ \.(?!\d) | [,?:(\[)\]}] | -- | \+\+ | && | \|\| | \*\*=? | [-+*\/%^~&|<>=!]=? | <<<?=? | >>>?=? /x)
@@ -42,6 +42,10 @@ module Scanners
42
42
  '"' => /[^\\"]+/,
43
43
  '/' => /[^\\\/]+/,
44
44
  }
45
+ KEY_CHECK_PATTERN = {
46
+ "'" => / [^\\']* (?: \\.? [^\\']* )* '? \s* : /x,
47
+ '"' => / [^\\"]* (?: \\.? [^\\"]* )* "? \s* : /x,
48
+ }
45
49
 
46
50
  def scan_tokens tokens, options
47
51
 
@@ -103,8 +107,12 @@ module Scanners
103
107
  key_expected = false
104
108
 
105
109
  elsif match = scan(/["']/)
106
- tokens << [:open, :string]
107
- state = :string
110
+ if key_expected && check(KEY_CHECK_PATTERN[match])
111
+ state = :key
112
+ else
113
+ state = :string
114
+ end
115
+ tokens << [:open, state]
108
116
  string_delimiter = match
109
117
  kind = :delimiter
110
118
 
@@ -125,7 +133,7 @@ module Scanners
125
133
 
126
134
  end
127
135
 
128
- when :string, :regexp
136
+ when :string, :regexp, :key
129
137
  if scan(STRING_CONTENT_PATTERN[string_delimiter])
130
138
  kind = :content
131
139
  elsif match = scan(/["'\/]/)
@@ -139,7 +147,7 @@ module Scanners
139
147
  key_expected = value_expected = false
140
148
  state = :initial
141
149
  next
142
- elsif state == :string && (match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox))
150
+ elsif state != :regexp && (match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox))
143
151
  if string_delimiter == "'" && !(match == "\\\\" || match == "\\'")
144
152
  kind = :content
145
153
  else
@@ -155,20 +163,20 @@ module Scanners
155
163
  key_expected = value_expected = false
156
164
  state = :initial
157
165
  else
158
- raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
166
+ raise_inspect "else case \" reached; %p not handled." % peek(1), tokens, state
159
167
  end
160
168
 
161
169
  else
162
- raise_inspect 'Unknown state', tokens
170
+ raise_inspect 'Unknown state', tokens, state
163
171
 
164
172
  end
165
173
 
166
174
  match ||= matched
167
175
  if $DEBUG and not kind
168
176
  raise_inspect 'Error token %p in line %d' %
169
- [[match, kind], line], tokens
177
+ [[match, kind], line], tokens, state
170
178
  end
171
- raise_inspect 'Empty token', tokens unless match
179
+ raise_inspect 'Empty token', tokens, state unless match
172
180
 
173
181
  tokens << [match, kind]
174
182
 
@@ -5,8 +5,6 @@ module Scanners
5
5
  load :ruby
6
6
 
7
7
  # Nitro XHTML Scanner
8
- #
9
- # $Id$
10
8
  class NitroXHTML < Scanner
11
9
 
12
10
  include Streamable
@@ -5,8 +5,6 @@ module Scanners
5
5
  load :ruby
6
6
 
7
7
  # RHTML Scanner
8
- #
9
- # $Id$
10
8
  class RHTML < Scanner
11
9
 
12
10
  include Streamable
@@ -5,8 +5,6 @@ module Scanners
5
5
 
6
6
  # XML Scanner
7
7
  #
8
- # $Id$
9
- #
10
8
  # Currently this is the same scanner as Scanners::HTML.
11
9
  class XML < HTML
12
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.303
4
+ version: 0.8.312
5
5
  platform: ruby
6
6
  authors:
7
7
  - murphy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-16 00:00:00 +01:00
12
+ date: 2009-02-23 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15