coderay 1.0.8 → 1.0.9.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/coderay/scanners/html.rb +1 -1
- data/lib/coderay/scanners/php.rb +2 -3
- data/lib/coderay/scanners/ruby.rb +21 -12
- data/lib/coderay/scanners/ruby/patterns.rb +18 -18
- data/lib/coderay/version.rb +1 -1
- metadata +9 -9
@@ -101,7 +101,7 @@ module Scanners
|
|
101
101
|
when :initial
|
102
102
|
if match = scan(/<!--(?:.*?-->|.*)/m)
|
103
103
|
encoder.text_token match, :comment
|
104
|
-
elsif match = scan(/<!
|
104
|
+
elsif match = scan(/<!(\w+)(?:.*?>|.*)|\]>/m)
|
105
105
|
encoder.text_token match, :doctype
|
106
106
|
elsif match = scan(/<\?xml(?:.*?\?>|.*)/m)
|
107
107
|
encoder.text_token match, :preprocessor
|
data/lib/coderay/scanners/php.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: utf-8
|
2
2
|
module CodeRay
|
3
3
|
module Scanners
|
4
4
|
|
@@ -11,7 +11,6 @@ module Scanners
|
|
11
11
|
|
12
12
|
register_for :php
|
13
13
|
file_extension 'php'
|
14
|
-
encoding 'BINARY'
|
15
14
|
|
16
15
|
KINDS_NOT_LOC = HTML::KINDS_NOT_LOC
|
17
16
|
|
@@ -211,7 +210,7 @@ module Scanners
|
|
211
210
|
|
212
211
|
HTML_INDICATOR = /<!DOCTYPE html|<(?:html|body|div|p)[> ]/i
|
213
212
|
|
214
|
-
IDENTIFIER = /[a-z_\x7f-\xFF][a-z0-9_\x7f-\xFF]
|
213
|
+
IDENTIFIER = 'ä'[/[[:alpha:]]/] == 'ä' ? Regexp.new('[[:alpha:]_[^\0-\177]][[:alnum:]_[^\0-\177]]*') : Regexp.new('[a-z_\x7f-\xFF][a-z0-9_\x7f-\xFF]*', true)
|
215
214
|
VARIABLE = /\$#{IDENTIFIER}/
|
216
215
|
|
217
216
|
OPERATOR = /
|
@@ -94,18 +94,27 @@ module Scanners
|
|
94
94
|
if !method_call_expected &&
|
95
95
|
match = scan(unicode ? /#{patterns::METHOD_NAME}/uo :
|
96
96
|
/#{patterns::METHOD_NAME}/o)
|
97
|
-
|
97
|
+
|
98
98
|
kind = patterns::IDENT_KIND[match]
|
99
|
-
if kind == :ident
|
100
|
-
|
101
|
-
|
99
|
+
if kind == :ident && value_expected != :colon_expected && scan(/:(?!:)/)
|
100
|
+
value_expected = true
|
101
|
+
encoder.text_token match, :key
|
102
|
+
encoder.text_token ':', :operator
|
103
|
+
else
|
104
|
+
value_expected = false
|
105
|
+
if kind == :ident
|
106
|
+
if match[/\A[A-Z]/] && !(match[/[!?]$/] || match?(/\(/))
|
107
|
+
kind = :constant
|
108
|
+
end
|
109
|
+
elsif kind == :keyword
|
110
|
+
state = patterns::KEYWORD_NEW_STATE[match]
|
111
|
+
if patterns::KEYWORDS_EXPECTING_VALUE[match]
|
112
|
+
value_expected = match == 'when' ? :colon_expected : true
|
113
|
+
end
|
102
114
|
end
|
103
|
-
|
104
|
-
|
105
|
-
value_expected = true if patterns::KEYWORDS_EXPECTING_VALUE[match]
|
115
|
+
value_expected = true if !value_expected && check(/#{patterns::VALUE_FOLLOWS}/o)
|
116
|
+
encoder.text_token match, kind
|
106
117
|
end
|
107
|
-
value_expected = true if !value_expected && check(/#{patterns::VALUE_FOLLOWS}/o)
|
108
|
-
encoder.text_token match, kind
|
109
118
|
|
110
119
|
elsif method_call_expected &&
|
111
120
|
match = scan(unicode ? /#{patterns::METHOD_AFTER_DOT}/uo :
|
@@ -119,9 +128,9 @@ module Scanners
|
|
119
128
|
value_expected = check(/#{patterns::VALUE_FOLLOWS}/o)
|
120
129
|
|
121
130
|
# OPERATORS #
|
122
|
-
elsif !method_call_expected && match = scan(/ (\.(?!\.)|::) | (
|
131
|
+
elsif !method_call_expected && match = scan(/ (\.(?!\.)|::) | ( \.\.\.? | ==?=? | [,\(\[\{] ) | [\)\]\}] /x)
|
123
132
|
method_call_expected = self[1]
|
124
|
-
value_expected = !method_call_expected && self[2]
|
133
|
+
value_expected = !method_call_expected && !!self[2]
|
125
134
|
if inline_block_stack
|
126
135
|
case match
|
127
136
|
when '{'
|
@@ -213,7 +222,7 @@ module Scanners
|
|
213
222
|
encoder.text_token match, :integer
|
214
223
|
|
215
224
|
elsif match = scan(/ %=? | <(?:<|=>?)? | \? /x)
|
216
|
-
value_expected = true
|
225
|
+
value_expected = match == '?' ? :colon_expected : true
|
217
226
|
encoder.text_token match, :operator
|
218
227
|
|
219
228
|
elsif match = scan(/`/)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module CodeRay
|
3
3
|
module Scanners
|
4
|
-
|
4
|
+
|
5
5
|
module Ruby::Patterns # :nodoc: all
|
6
|
-
|
6
|
+
|
7
7
|
KEYWORDS = %w[
|
8
8
|
and def end in or unless begin
|
9
9
|
defined? ensure module redo super until
|
@@ -12,7 +12,7 @@ module Scanners
|
|
12
12
|
while alias class elsif if not return
|
13
13
|
undef yield
|
14
14
|
]
|
15
|
-
|
15
|
+
|
16
16
|
# See http://murfy.de/ruby-constants.
|
17
17
|
PREDEFINED_CONSTANTS = %w[
|
18
18
|
nil true false self
|
@@ -24,19 +24,19 @@ module Scanners
|
|
24
24
|
RUBY_PLATFORM RUBY_RELEASE_DATE RUBY_REVISION RUBY_VERSION
|
25
25
|
__FILE__ __LINE__ __ENCODING__
|
26
26
|
]
|
27
|
-
|
27
|
+
|
28
28
|
IDENT_KIND = WordList.new(:ident).
|
29
29
|
add(KEYWORDS, :keyword).
|
30
30
|
add(PREDEFINED_CONSTANTS, :predefined_constant)
|
31
|
-
|
31
|
+
|
32
32
|
KEYWORD_NEW_STATE = WordList.new(:initial).
|
33
33
|
add(%w[ def ], :def_expected).
|
34
34
|
add(%w[ undef ], :undef_expected).
|
35
35
|
add(%w[ alias ], :alias_expected).
|
36
36
|
add(%w[ class module ], :module_expected)
|
37
|
-
|
38
|
-
IDENT = 'ä'[/[[:alpha:]]/] == 'ä' ?
|
39
|
-
|
37
|
+
|
38
|
+
IDENT = 'ä'[/[[:alpha:]]/] == 'ä' ? Regexp.new('[[:alpha:]_[^\0-\177]][[:alnum:]_[^\0-\177]]*') : /[^\W\d]\w*/
|
39
|
+
|
40
40
|
METHOD_NAME = / #{IDENT} [?!]? /ox
|
41
41
|
METHOD_NAME_OPERATOR = /
|
42
42
|
\*\*? # multiplication and power
|
@@ -57,25 +57,25 @@ module Scanners
|
|
57
57
|
GLOBAL_VARIABLE = / \$ (?: #{IDENT} | [1-9]\d* | 0\w* | [~&+`'=\/,;_.<>!@$?*":\\] | -[a-zA-Z_0-9] ) /ox
|
58
58
|
PREFIX_VARIABLE = / #{GLOBAL_VARIABLE} | #{OBJECT_VARIABLE} /ox
|
59
59
|
VARIABLE = / @?@? #{IDENT} | #{GLOBAL_VARIABLE} /ox
|
60
|
-
|
60
|
+
|
61
61
|
QUOTE_TO_TYPE = {
|
62
62
|
'`' => :shell,
|
63
63
|
'/'=> :regexp,
|
64
64
|
}
|
65
65
|
QUOTE_TO_TYPE.default = :string
|
66
|
-
|
66
|
+
|
67
67
|
REGEXP_MODIFIERS = /[mousenix]*/
|
68
|
-
|
68
|
+
|
69
69
|
DECIMAL = /\d+(?:_\d+)*/
|
70
70
|
OCTAL = /0_?[0-7]+(?:_[0-7]+)*/
|
71
71
|
HEXADECIMAL = /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/
|
72
72
|
BINARY = /0b[01]+(?:_[01]+)*/
|
73
|
-
|
73
|
+
|
74
74
|
EXPONENT = / [eE] [+-]? #{DECIMAL} /ox
|
75
75
|
FLOAT_SUFFIX = / #{EXPONENT} | \. #{DECIMAL} #{EXPONENT}? /ox
|
76
76
|
FLOAT_OR_INT = / #{DECIMAL} (?: #{FLOAT_SUFFIX} () )? /ox
|
77
77
|
NUMERIC = / (?: (?=0) (?: #{OCTAL} | #{HEXADECIMAL} | #{BINARY} ) | #{FLOAT_OR_INT} ) /ox
|
78
|
-
|
78
|
+
|
79
79
|
SYMBOL = /
|
80
80
|
:
|
81
81
|
(?:
|
@@ -85,7 +85,7 @@ module Scanners
|
|
85
85
|
)
|
86
86
|
/ox
|
87
87
|
METHOD_NAME_OR_SYMBOL = / #{METHOD_NAME_EX} | #{SYMBOL} /ox
|
88
|
-
|
88
|
+
|
89
89
|
SIMPLE_ESCAPE = /
|
90
90
|
[abefnrstv]
|
91
91
|
| [0-7]{1,3}
|
@@ -110,7 +110,7 @@ module Scanners
|
|
110
110
|
| \\ #{ESCAPE}
|
111
111
|
)
|
112
112
|
/mox
|
113
|
-
|
113
|
+
|
114
114
|
# NOTE: This is not completely correct, but
|
115
115
|
# nobody needs heredoc delimiters ending with \n.
|
116
116
|
HEREDOC_OPEN = /
|
@@ -122,13 +122,13 @@ module Scanners
|
|
122
122
|
( [^\n]*? ) \3 # $4 = delim
|
123
123
|
)
|
124
124
|
/mx
|
125
|
-
|
125
|
+
|
126
126
|
RUBYDOC = /
|
127
127
|
=begin (?!\S)
|
128
128
|
.*?
|
129
129
|
(?: \Z | ^=end (?!\S) [^\n]* )
|
130
130
|
/mx
|
131
|
-
|
131
|
+
|
132
132
|
DATA = /
|
133
133
|
__END__$
|
134
134
|
.*?
|
@@ -136,7 +136,7 @@ module Scanners
|
|
136
136
|
/mx
|
137
137
|
|
138
138
|
RUBYDOC_OR_DATA = / #{RUBYDOC} | #{DATA} /xo
|
139
|
-
|
139
|
+
|
140
140
|
# Checks for a valid value to follow. This enables
|
141
141
|
# value_expected in method calls without parentheses.
|
142
142
|
VALUE_FOLLOWS = /
|
data/lib/coderay/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coderay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.9.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kornelius Kalnbach
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Fast and easy syntax highlighting for selected languages, written in
|
15
15
|
Ruby. Comes with RedCloth integration and LOC counter.
|
@@ -90,10 +90,10 @@ files:
|
|
90
90
|
- test/functional/examples.rb
|
91
91
|
- test/functional/for_redcloth.rb
|
92
92
|
- test/functional/suite.rb
|
93
|
-
-
|
94
|
-
YmluL2NvZGVyYXk=
|
93
|
+
- bin/coderay
|
95
94
|
homepage: http://coderay.rubychan.de
|
96
|
-
licenses:
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
97
|
post_install_message:
|
98
98
|
rdoc_options:
|
99
99
|
- -SNw2
|
@@ -110,12 +110,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
113
|
-
- - ! '
|
113
|
+
- - ! '>'
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
115
|
+
version: 1.3.1
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project: coderay
|
118
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.25
|
119
119
|
signing_key:
|
120
120
|
specification_version: 3
|
121
121
|
summary: Fast syntax highlighting for selected languages.
|