From 68d9a901b27eb2b648488f9b147d6d3eedefde04 Mon Sep 17 00:00:00 2001 From: Alexandre Vezina Date: Sat, 23 Mar 2013 13:46:01 -0400 Subject: Support for phtml files --- lib/coderay/helpers/file_type.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/coderay') diff --git a/lib/coderay/helpers/file_type.rb b/lib/coderay/helpers/file_type.rb index 637001b..b137448 100644 --- a/lib/coderay/helpers/file_type.rb +++ b/lib/coderay/helpers/file_type.rb @@ -99,6 +99,7 @@ module CodeRay 'mab' => :ruby, 'pas' => :delphi, 'patch' => :diff, + 'phtml' => :html, 'php' => :php, 'php3' => :php, 'php4' => :php, -- cgit v1.2.1 From 2f285f3d2803ef9742af240a1e5935a2dfc915fc Mon Sep 17 00:00:00 2001 From: Alexandre Vezina Date: Wed, 17 Apr 2013 14:45:16 -0400 Subject: PHP is a better highlight for phtml files --- lib/coderay/helpers/file_type.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/coderay') diff --git a/lib/coderay/helpers/file_type.rb b/lib/coderay/helpers/file_type.rb index b137448..f52f17e 100644 --- a/lib/coderay/helpers/file_type.rb +++ b/lib/coderay/helpers/file_type.rb @@ -99,7 +99,7 @@ module CodeRay 'mab' => :ruby, 'pas' => :delphi, 'patch' => :diff, - 'phtml' => :html, + 'phtml' => :php, 'php' => :php, 'php3' => :php, 'php4' => :php, -- cgit v1.2.1 From 57ffbc753f8e7fd676a13bf5960043b23ee1d5ed Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 04:30:23 +0200 Subject: unfreeze TokenKinds hash, allow changes --- lib/coderay/token_kinds.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/coderay') diff --git a/lib/coderay/token_kinds.rb b/lib/coderay/token_kinds.rb index 3b8d07e..8db8530 100755 --- a/lib/coderay/token_kinds.rb +++ b/lib/coderay/token_kinds.rb @@ -85,6 +85,4 @@ module CodeRay TokenKinds[:method] = TokenKinds[:function] TokenKinds[:escape] = TokenKinds[:delimiter] TokenKinds[:docstring] = TokenKinds[:comment] - - TokenKinds.freeze end -- cgit v1.2.1 From 1952ef4c4dd1105665a3a4f9a0266598d6acf892 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 06:22:39 +0200 Subject: two fixes for CSS scanner --- lib/coderay/scanners/css.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/coderay') diff --git a/lib/coderay/scanners/css.rb b/lib/coderay/scanners/css.rb index 7b731ef..dd5106e 100644 --- a/lib/coderay/scanners/css.rb +++ b/lib/coderay/scanners/css.rb @@ -27,7 +27,7 @@ module Scanners HexColor = /#(?:#{Hex}{6}|#{Hex}{3})/ Color = /#{HexColor}/ - Num = /-?(?:[0-9]+|[0-9]*\.[0-9]+)/ + Num = /-?(?:[0-9]+(?!\.\d)|[0-9]*\.[0-9]+)/ Name = /#{NMChar}+/ Ident = /-?#{NMStart}#{NMChar}*/ AtKeyword = /@#{Ident}/ @@ -44,7 +44,7 @@ module Scanners Id = /##{Name}/ Class = /\.#{Name}/ - PseudoClass = /:#{Name}/ + PseudoClass = /::?#{Name}/ AttributeSelector = /\[[^\]]*\]?/ end -- cgit v1.2.1 From 2347f995a70d7607fc0e417c5c7323eacfdcc341 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 06:23:48 +0200 Subject: treat empty token as error in Debug encoder --- lib/coderay/encoders/debug.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/coderay') diff --git a/lib/coderay/encoders/debug.rb b/lib/coderay/encoders/debug.rb index 62f9f0a..c03d3fb 100644 --- a/lib/coderay/encoders/debug.rb +++ b/lib/coderay/encoders/debug.rb @@ -24,6 +24,7 @@ module Encoders end def text_token text, kind + raise 'empty token' if $CODERAY_DEBUG && text.empty? if kind == :space @out << text else -- cgit v1.2.1 From 667d4262e42b5866859fb9eb91a0617c1722e7a4 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 06:24:29 +0200 Subject: avoid empty tokens in Diff output, fix split_into_parts --- lib/coderay/scanners/diff.rb | 2 +- lib/coderay/tokens.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/coderay') diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb index 38efaf4..8e3bf3c 100644 --- a/lib/coderay/scanners/diff.rb +++ b/lib/coderay/scanners/diff.rb @@ -45,7 +45,7 @@ module Scanners if match = scan(/--- |\+\+\+ |=+|_+/) encoder.begin_line line_kind = :head encoder.text_token match, :head - if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/) + if match = scan(/.+?(?=$|[\t\n\x00]| \(revision)/) encoder.text_token match, :filename if options[:highlight_code] && match != '/dev/null' file_type = CodeRay::FileType.fetch(match, :text) diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb index c747017..6957d69 100644 --- a/lib/coderay/tokens.rb +++ b/lib/coderay/tokens.rb @@ -93,6 +93,7 @@ module CodeRay # This method is used by @Scanner#tokenize@ when called with an Array # of source strings. The Diff encoder uses it for inline highlighting. def split_into_parts *sizes + return Array.new(sizes.size) { Tokens.new } if size == 2 && first == '' parts = [] opened = [] content = nil -- cgit v1.2.1 From 4323bb7ad9b5c5ddc770691d66e5727553ca33a3 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 06:27:14 +0200 Subject: bump version to 1.1.0 --- lib/coderay/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/coderay') diff --git a/lib/coderay/version.rb b/lib/coderay/version.rb index bfb5f24..4b4f085 100644 --- a/lib/coderay/version.rb +++ b/lib/coderay/version.rb @@ -1,3 +1,3 @@ module CodeRay - VERSION = '1.0.9' + VERSION = '1.1.0' end -- cgit v1.2.1 From 1ad75645ad880ede3c0590fd6a700b1847cc3fe4 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 07:14:12 +0200 Subject: don't allow \x00 in diff filenames --- lib/coderay/scanners/diff.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/coderay') diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb index 8e3bf3c..af0f755 100644 --- a/lib/coderay/scanners/diff.rb +++ b/lib/coderay/scanners/diff.rb @@ -45,7 +45,7 @@ module Scanners if match = scan(/--- |\+\+\+ |=+|_+/) encoder.begin_line line_kind = :head encoder.text_token match, :head - if match = scan(/.+?(?=$|[\t\n\x00]| \(revision)/) + if match = scan(/[^\x00\n]+?(?=$|[\t\n]| \(revision)/) encoder.text_token match, :filename if options[:highlight_code] && match != '/dev/null' file_type = CodeRay::FileType.fetch(match, :text) -- cgit v1.2.1 From 737fb3608c92506a573a79f611b94ff5d5da18e6 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 9 Jun 2013 07:25:15 +0200 Subject: do not warn about plugin fallback --- lib/coderay/helpers/plugin.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/coderay') diff --git a/lib/coderay/helpers/plugin.rb b/lib/coderay/helpers/plugin.rb index 137c1ab..dd4e830 100644 --- a/lib/coderay/helpers/plugin.rb +++ b/lib/coderay/helpers/plugin.rb @@ -180,7 +180,6 @@ module CodeRay rescue LoadError => boom if @plugin_map_loaded if h.has_key?(:default) - warn '%p could not load plugin %p; falling back to %p' % [self, id, h[:default]] h[:default] else raise PluginNotFound, '%p could not load plugin %p: %s' % [self, id, boom] -- cgit v1.2.1