From d666db48604418eed5aaf76669375e2c9b2bd101 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 17 Feb 2013 21:49:50 +0100 Subject: [PATCH] fix #40 (PHP unicode) --- Changes.textile | 1 + lib/coderay/scanners/php.rb | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Changes.textile b/Changes.textile index 877103ad..dc647929 100644 --- a/Changes.textile +++ b/Changes.textile @@ -8,6 +8,7 @@ h2. Changes in 1.0.9 * Fix Ruby scanner: Ruby 1.9 hash syntax @{ key: value }@ is highlighted correctly. [GH #106, thanks to Seth Vargo] * Fix HTML scanner: Accept DTDs. [GH #83] +* Fix PHP scanner: Accept Unicode. [GH #40] h2. Changes in 1.0.8 diff --git a/lib/coderay/scanners/php.rb b/lib/coderay/scanners/php.rb index 8acfff53..3f7ff6a0 100644 --- a/lib/coderay/scanners/php.rb +++ b/lib/coderay/scanners/php.rb @@ -1,4 +1,4 @@ -# encoding: ASCII-8BIT +# encoding: utf-8 module CodeRay module Scanners @@ -11,7 +11,6 @@ class PHP < Scanner register_for :php file_extension 'php' - encoding 'BINARY' KINDS_NOT_LOC = HTML::KINDS_NOT_LOC @@ -211,7 +210,7 @@ module RE # :nodoc: HTML_INDICATOR = / ]/i - IDENTIFIER = /[a-z_\x7f-\xFF][a-z0-9_\x7f-\xFF]*/i + IDENTIFIER = 'ä'[/[[:alpha:]]/] == 'ä' ? Regexp.new('[[:alpha:]_[^\0-\177]][[:alnum:]_[^\0-\177]]*') : Regexp.new('[a-z_\17f-\xFF][a-z0-9_\x7f-\xFF]*/', true) VARIABLE = /\$#{IDENTIFIER}/ OPERATOR = /