coderay_bash 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  # vi: fenc=utf-8:expandtab:ts=2:sw=2:sts=2
3
3
  #
4
4
  # @author: Petr Kovar <pejuko@gmail.com>
5
- $KCODE='UTF8'
5
+ $KCODE='UTF8' if RUBY_VERSION < "1.9"
6
6
 
7
7
  require 'rake/gempackagetask'
8
8
  require 'rake/testtask'
data/coderay_bash.gemspec CHANGED
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
13
13
  s.email = "pejuko@gmail.com"
14
14
  s.authors = ["Petr Kovar"]
15
15
  s.name = 'coderay_bash'
16
- s.version = '0.2.0'
16
+ s.version = '0.2.1'
17
17
  s.date = Time.now.strftime("%Y-%m-%d")
18
18
  s.add_dependency('coderay', '< 1.0')
19
19
  s.require_path = 'lib'
@@ -106,7 +106,7 @@ module Scanners
106
106
  kind = :shell
107
107
  elsif match = scan(PRE_CONSTANTS)
108
108
  kind = :pre_constant
109
- elsif match = scan(/[^\s]*[A-Za-z_][A-Za-z_0-9]*\+?=/)
109
+ elsif match = scan(/[^\s'"]*[A-Za-z_][A-Za-z_0-9]*\+?=/)
110
110
  match =~ /(.*?)([A-Za-z_][A-Za-z_0-9]*)(\+?=)/
111
111
  str = $1
112
112
  pre = $2
@@ -151,8 +151,7 @@ module Scanners
151
151
  kind = :plain
152
152
  elsif match = scan(/.+/)
153
153
  # this shouldn't be :reserved for highlighting bad matches
154
- kind = :error
155
- match = ">>>>>#{match}<<<<<"
154
+ match, kind = handle_error(match, options)
156
155
  end
157
156
  elsif @state == :quote
158
157
  if (match = scan(/\\.?/))
@@ -179,9 +178,8 @@ module Scanners
179
178
  else match = scan(/.+/)
180
179
  # this shouldn't be
181
180
  #kind = :reserved
182
- #raise match
183
- match = ">>>>>#{match}<<<<<"
184
- kind = :error
181
+ #raise match
182
+ match, kind = handle_error(match, options)
185
183
  end
186
184
  end
187
185
 
@@ -191,6 +189,16 @@ module Scanners
191
189
 
192
190
  tokens
193
191
  end
192
+
193
+
194
+ def handle_error(match, options)
195
+ o = {:ignore_errors => true}.merge(options)
196
+ if o[:ignore_errors]
197
+ [match, :plain]
198
+ else
199
+ [">>>>>#{match}<<<<<", :error]
200
+ end
201
+ end
194
202
 
195
203
  end
196
204
  end
@@ -11,7 +11,7 @@ module CodeRay
11
11
  def setup
12
12
  super
13
13
  # Scan Bash instead of HTML template
14
- @html_scanner = CodeRay.scanner :bash, :tokens => @tokens, :keep_tokens => true
14
+ @html_scanner = CodeRay.scanner :bash, @options.merge(:tokens => @tokens, :keep_tokens => true)
15
15
  end
16
16
  end
17
17
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Petr Kovar
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-08 00:00:00 +01:00
17
+ date: 2011-03-30 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -45,9 +45,9 @@ files:
45
45
  - README.md
46
46
  - coderay_bash.gemspec
47
47
  - Rakefile
48
- - lib/coderay_bash.rb
49
- - lib/coderay/scanners/bash.rb
50
48
  - lib/coderay/scanners/erb_bash.rb
49
+ - lib/coderay/scanners/bash.rb
50
+ - lib/coderay_bash.rb
51
51
  has_rdoc: true
52
52
  homepage: http://github.com/pejuko/coderay_bash
53
53
  licenses: []