summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2014-12-18 21:28:24 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2014-12-18 21:28:24 +0100
commit7aa6ea080d05b7e6a70b076b25f37b72fd7669ad (patch)
tree5134dda976acfa6746a53fd9def12937701d9850
parentbc4854fa426a39c2bd51b2fd1cfa0322a5a9a412 (diff)
parent31a09b7599fb7c4b605869127e38617ce7619106 (diff)
downloadcoderay-7aa6ea080d05b7e6a70b076b25f37b72fd7669ad.tar.gz
Merge branch 'master' into possible-speedups
Conflicts: lib/coderay/encoders/html.rb
-rw-r--r--.travis.yml2
-rw-r--r--Changes.textile4
-rw-r--r--Gemfile7
-rw-r--r--README.markdown2
-rw-r--r--lib/coderay/encoders/html.rb2
-rw-r--r--lib/coderay/scanners/sql.rb40
-rw-r--r--lib/coderay/version.rb2
7 files changed, 29 insertions, 30 deletions
diff --git a/.travis.yml b/.travis.yml
index 6d926f3..8e18c0a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,6 +3,8 @@ rvm:
- ree
- 1.9.3
- 2.0.0
+ - 2.1
+ - 2.2
- ruby-head
- jruby-18mode
- jruby-19mode
diff --git a/Changes.textile b/Changes.textile
index 8e388e0..137460a 100644
--- a/Changes.textile
+++ b/Changes.textile
@@ -2,6 +2,10 @@ h1=. CodeRay Version History
p=. _This files lists all changes in the CodeRay library since the 0.9.8 release._
+h2. Changes in 1.1.1
+
+* SQL scanner: fix open strings [#163, thanks to Adam]
+
h2. Changes in 1.1
New scanners:
diff --git a/Gemfile b/Gemfile
index 15a71ae..0fae04b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,11 +6,12 @@ gemspec
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
- gem "bundler", ">= 1.0.0"
+ gem "bundler"
gem "rake"
gem "RedCloth", RUBY_PLATFORM == 'java' ? ">= 4.2.7" : ">= 4.0.3"
- gem "term-ansicolor", '~> 1.2.2'
- gem "shoulda-context", "~> 1.1.2"
+ gem "term-ansicolor"
+ gem "shoulda-context"
+ gem "test-unit"
gem "json" if RUBY_VERSION < '1.9'
gem "rdoc"
end
diff --git a/README.markdown b/README.markdown
index e23f603..15b3447 100644
--- a/README.markdown
+++ b/README.markdown
@@ -16,7 +16,7 @@ You put your code in, and you get it back colored; Keywords, strings, floats, co
### Dependencies
-CodeRay needs Ruby 1.8.7, 1.9.3 or 2.0. It also runs on JRuby.
+CodeRay needs Ruby 1.8.7, 1.9.3 or 2.0+. It also runs on JRuby.
## Example Usage
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index 7e83eb8..a2c274f 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -280,7 +280,7 @@ module Encoders
if options[:tab_width] == DEFAULT_OPTIONS[:tab_width]
HTML_ESCAPE
else
- HTML_ESCAPE.merge("\t" => ' ' * options[:tab_width])
+ HTML_ESCAPE.merge("\t" => options[:tab_width] ? ' ' * options[:tab_width] : "\t")
end
Hash.new do |cache, text|
diff --git a/lib/coderay/scanners/sql.rb b/lib/coderay/scanners/sql.rb
index 93aeaf3..c25f6d2 100644
--- a/lib/coderay/scanners/sql.rb
+++ b/lib/coderay/scanners/sql.rb
@@ -57,6 +57,12 @@ module Scanners
STRING_PREFIXES = /[xnb]|_\w+/i
+ STRING_CONTENT_PATTERN = {
+ '"' => / (?: [^\\"] | "" )+ /x,
+ "'" => / (?: [^\\'] | '' )+ /x,
+ '`' => / (?: [^\\`] | `` )+ /x,
+ }
+
def scan_tokens encoder, options
state = :initial
@@ -115,40 +121,26 @@ module Scanners
end
elsif state == :string
- if match = scan(/[^\\"'`]+/)
- string_content << match
- next
+ if match = scan(STRING_CONTENT_PATTERN[string_type])
+ encoder.text_token match, :content
elsif match = scan(/["'`]/)
if string_type == match
if peek(1) == string_type # doubling means escape
- string_content << string_type << getch
- next
- end
- unless string_content.empty?
- encoder.text_token string_content, :content
- string_content = ''
+ encoder.text_token match + getch, :content
+ else
+ encoder.text_token match, :delimiter
+ encoder.end_group :string
+ state = :initial
+ string_type = nil
end
- encoder.text_token match, :delimiter
- encoder.end_group :string
- state = :initial
- string_type = nil
else
- string_content << match
+ encoder.text_token match, :content
end
elsif match = scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
- unless string_content.empty?
- encoder.text_token string_content, :content
- string_content = ''
- end
encoder.text_token match, :char
elsif match = scan(/ \\ . /mox)
- string_content << match
- next
+ encoder.text_token match, :content
elsif match = scan(/ \\ | $ /x)
- unless string_content.empty?
- encoder.text_token string_content, :content
- string_content = ''
- end
encoder.text_token match, :error unless match.empty?
encoder.end_group :string
state = :initial
diff --git a/lib/coderay/version.rb b/lib/coderay/version.rb
index 4b4f085..7ea3f70 100644
--- a/lib/coderay/version.rb
+++ b/lib/coderay/version.rb
@@ -1,3 +1,3 @@
module CodeRay
- VERSION = '1.1.0'
+ VERSION = '1.1.1'
end