coderay 0.8.312 → 0.8.357

Sign up to get free protection for your applications and to get access to all the features.
data/lib/README CHANGED
@@ -18,7 +18,7 @@ And with line numbers.
18
18
  * is what everybody should have on their website
19
19
  * solves all your problems and makes the girls run after you
20
20
 
21
- Version: 0.8.3
21
+ Version: 0.8.4
22
22
  Author:: murphy (Kornelius Kalnbach)
23
23
  Contact:: murphy rubychan de
24
24
  Website:: coderay.rubychan.de[http://coderay.rubychan.de]
@@ -15,7 +15,9 @@ module CodeRay
15
15
  def self.install
16
16
  gem 'RedCloth', '>= 4.0.3' rescue nil
17
17
  require 'redcloth'
18
- raise 'CodeRay.for_redcloth needs RedCloth 4.0.3 or later.' unless RedCloth::VERSION.to_s >= '4.0.3'
18
+ unless RedCloth::VERSION.to_s >= '4.0.3'
19
+ raise 'CodeRay.for_redcloth needs RedCloth version 4.0.3 or later.'
20
+ end
19
21
  RedCloth::TextileDoc.send :include, ForRedCloth::TextileDoc
20
22
  RedCloth::Formatters::HTML.module_eval do
21
23
  def unescape(html)
@@ -30,6 +32,11 @@ module CodeRay
30
32
  undef_method :code, :bc_open, :bc_close, :escape_pre
31
33
  def code(opts) # :nodoc:
32
34
  opts[:block] = true
35
+ if !opts[:lang] && RedCloth::VERSION.to_s >= '4.2.0'
36
+ # simulating pre-4.2 behavior
37
+ opts[:text].sub!(/\A\[(\w+)\]/, '')
38
+ opts[:lang] = $1
39
+ end
33
40
  if opts[:lang] && !filter_coderay
34
41
  require 'coderay'
35
42
  @in_bc ||= nil
@@ -175,7 +175,7 @@ module Scanners
175
175
  ## experimental!
176
176
  value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o)
177
177
 
178
- elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o)
178
+ elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}|\(/o)
179
179
  kind = :ident
180
180
  value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o)
181
181
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.312
4
+ version: 0.8.357
5
5
  platform: ruby
6
6
  authors:
7
7
  - murphy
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-23 00:00:00 +01:00
12
+ date: 2009-10-02 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: "CodeRay is a Ruby library for syntax highlighting. I try to make CodeRay easy to use and intuitive, but at the same time fully featured, complete, fast and efficient. Usage is simple: require 'coderay' code = 'some %q(weird (Ruby) can't shock) me!' puts CodeRay.scan(code, :ruby).html"
16
+ description: " CodeRay is a Ruby library for syntax highlighting.\n I try to make CodeRay easy to use and intuitive, but at the same time\n fully featured, complete, fast and efficient.\n\n Usage is simple:\n require 'coderay'\n code = 'some %q(weird (Ruby) can't shock) me!'\n puts CodeRay.scan(code, :ruby).html\n"
17
17
  email: murphy@rubychan.de
18
18
  executables:
19
19
  - coderay
@@ -65,8 +65,6 @@ files:
65
65
  - ./lib/coderay/scanners/ruby/patterns.rb
66
66
  - ./lib/coderay/scanners/ruby.rb
67
67
  - ./lib/coderay/scanners/scheme.rb
68
- - ./lib/coderay/scanners/sql.Keith.rb
69
- - ./lib/coderay/scanners/sql.rb
70
68
  - ./lib/coderay/scanners/xml.rb
71
69
  - ./lib/coderay/scanners/yaml.rb
72
70
  - ./lib/coderay/style.rb
@@ -82,6 +80,8 @@ files:
82
80
  - ./FOLDERS
83
81
  has_rdoc: true
84
82
  homepage: http://coderay.rubychan.de
83
+ licenses: []
84
+
85
85
  post_install_message:
86
86
  rdoc_options:
87
87
  - -SNw2
@@ -105,9 +105,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements: []
106
106
 
107
107
  rubyforge_project: coderay
108
- rubygems_version: 1.3.1
108
+ rubygems_version: 1.3.5
109
109
  signing_key:
110
- specification_version: 2
110
+ specification_version: 3
111
111
  summary: CodeRay is a fast syntax highlighter engine for many languages.
112
112
  test_files: []
113
113
 
@@ -1,143 +0,0 @@
1
- module CodeRay
2
- module Scanners
3
-
4
- # by Keith Pitt
5
- class SQL < Scanner
6
-
7
- register_for :sql
8
-
9
- include Streamable
10
-
11
- RESERVED_WORDS = %w(
12
- all alter and any as asc at authid avg begin between
13
- body bulk by case char check close cluster coalesce
14
- collect comment commit compress connect constant create
15
- current currval cursor day declare default delete
16
- desc distinct do drop else elsif end exception exclusive
17
- execute exists exit extends extract fetch for forall
18
- from function goto group having heap hour if immediate in
19
- index indicator insert interface intersect
20
- interval into is isolation java level like limited lock
21
- loop max min minus minute mlslabel mod mode month natural
22
- naturaln new nextval nocopy not nowait null nullif
23
- number_base ocirowid of on opaque open operator option or
24
- order organization others out package partition pctfree
25
- pls_integer positive positiven pragma prior private procedure
26
- public raise range raw real record ref release return reverse
27
- rollback row rowid rownum rowtype savepoint second select
28
- separate set share space sql sqlcode sqlerrm start
29
- stddev subtype successful sum synonym sysdate table then
30
- timezone_region timezone_abbr timezone_minute
31
- to trigger true type uid union unique update
32
- use user validate values variance view when
33
- whenever where while with work write year zone
34
- )
35
-
36
- PREDEFINED_TYPES = %w(
37
- array bigint bit binary blob boolean binary_integer char
38
- character clob date decimal double float char_base
39
- int integer nchar nclob smallint timestamp long number
40
- timestamp_hour timestamp_minute varchar varying smallint
41
- varchar2 nvarchar money time
42
- )
43
-
44
- PREDEFINED_CONSTANTS = %w(
45
- NULL true false
46
- )
47
-
48
- IDENT_KIND = CaseIgnoringWordList.new(:ident).
49
- add(RESERVED_WORDS, :reserved).
50
- add(PREDEFINED_TYPES, :pre_type).
51
- add(PREDEFINED_CONSTANTS, :pre_constant)
52
-
53
- def scan_tokens tokens, options
54
-
55
- state = :initial
56
-
57
- until eos?
58
-
59
- kind = nil
60
- match = nil
61
-
62
- case state
63
-
64
- when :initial
65
-
66
- if scan(/ \s+ | \\\n /x)
67
- kind = :space
68
-
69
- elsif scan(%r! -- [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
70
- kind = :comment
71
-
72
- elsif scan(/ [-+*\/=<>?:;,!&^|()~%]+ | \.(?!\d) /x)
73
- kind = :operator
74
-
75
- elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
76
- kind = IDENT_KIND[match]
77
- if kind == :ident and check(/:(?!:)/)
78
- match << scan(/:/)
79
- kind = :label
80
- end
81
-
82
- elsif match = scan(/'/)
83
- tokens << [:open, :string]
84
- state = :string
85
- kind = :delimiter
86
-
87
- elsif scan(/(?:\d+)(?![.eEfF])/)
88
- kind = :integer
89
-
90
- elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
91
- kind = :float
92
-
93
- else
94
- getch
95
- kind = :error
96
-
97
- end
98
-
99
- when :string
100
- if scan(/[^\\\n']+/)
101
- kind = :content
102
- elsif scan(/'/)
103
- tokens << ["'", :delimiter]
104
- tokens << [:close, :string]
105
- state = :initial
106
- next
107
- elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
108
- kind = :char
109
- elsif scan(/ \\ | $ /x)
110
- tokens << [:close, :string]
111
- kind = :error
112
- state = :initial
113
- else
114
- raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
115
- end
116
-
117
- else
118
- raise_inspect 'Unknown state', tokens
119
-
120
- end
121
-
122
- match ||= matched
123
- if $DEBUG and not kind
124
- raise_inspect 'Error token %p in line %d' %
125
- [[match, kind], line], tokens
126
- end
127
- raise_inspect 'Empty token', tokens unless match
128
-
129
- tokens << [match, kind]
130
-
131
- end
132
-
133
- if state == :string
134
- tokens << [:close, :string]
135
- end
136
-
137
- tokens
138
- end
139
-
140
- end
141
-
142
- end
143
- end
@@ -1,154 +0,0 @@
1
- module CodeRay module Scanners
2
-
3
- # by Josh Goebel
4
- class SQL < Scanner
5
-
6
- register_for :sql
7
-
8
- RESERVED_WORDS = %w(
9
- create table index trigger drop primary key set select
10
- insert update delete replace into
11
- on from values before and or if exists case when
12
- then else as group order by avg where
13
- join inner outer union engine not
14
- like
15
- )
16
-
17
- PREDEFINED_TYPES = %w(
18
- char varchar enum binary text tinytext mediumtext
19
- longtext blob tinyblob mediumblob longblob timestamp
20
- date time datetime year double decimal float int
21
- integer tinyint mediumint bigint smallint unsigned bit
22
- bool boolean
23
- )
24
-
25
- PREDEFINED_FUNCTIONS = %w( sum cast abs pi count min max avg )
26
-
27
- DIRECTIVES = %w( auto_increment unique default charset )
28
-
29
- PREDEFINED_CONSTANTS = %w( null true false )
30
-
31
- IDENT_KIND = CaseIgnoringWordList.new(:ident).
32
- add(RESERVED_WORDS, :reserved).
33
- add(PREDEFINED_TYPES, :pre_type).
34
- add(PREDEFINED_CONSTANTS, :pre_constant).
35
- add(PREDEFINED_FUNCTIONS, :predefined).
36
- add(DIRECTIVES, :directive)
37
-
38
- ESCAPE = / [rbfnrtv\n\\\/'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
39
- UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
40
-
41
- def scan_tokens tokens, options
42
-
43
- state = :initial
44
- string_type = nil
45
- string_content = ''
46
-
47
- until eos?
48
-
49
- kind = nil
50
- match = nil
51
-
52
- if state == :initial
53
-
54
- if scan(/ \s+ | \\\n /x)
55
- kind = :space
56
-
57
- elsif scan(/^(?:--\s|#).*/)
58
- kind = :comment
59
-
60
- elsif scan(%r! /\* (?: .*? \*/ | .* ) !mx)
61
- kind = :comment
62
-
63
- elsif scan(/ [-+*\/=<>;,!&^|()\[\]{}~%] | \.(?!\d) /x)
64
- kind = :operator
65
-
66
- elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
67
- kind = IDENT_KIND[match.downcase]
68
-
69
- elsif match = scan(/[`"']/)
70
- tokens << [:open, :string]
71
- string_type = matched
72
- state = :string
73
- kind = :delimiter
74
-
75
- elsif scan(/0[xX][0-9A-Fa-f]+/)
76
- kind = :hex
77
-
78
- elsif scan(/0[0-7]+(?![89.eEfF])/)
79
- kind = :oct
80
-
81
- elsif scan(/\d+(?![.eEfF])/)
82
- kind = :integer
83
-
84
- elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
85
- kind = :float
86
-
87
- else
88
- getch
89
- kind = :error
90
-
91
- end
92
-
93
- elsif state == :string
94
- if match = scan(/[^\\"'`]+/)
95
- string_content << match
96
- next
97
- elsif match = scan(/["'`]/)
98
- if string_type == match
99
- if peek(1) == string_type # doubling means escape
100
- string_content << string_type << getch
101
- next
102
- end
103
- unless string_content.empty?
104
- tokens << [string_content, :content]
105
- string_content = ''
106
- end
107
- tokens << [matched, :delimiter]
108
- tokens << [:close, :string]
109
- state = :initial
110
- string_type = nil
111
- next
112
- else
113
- string_content << match
114
- end
115
- next
116
- elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
117
- unless string_content.empty?
118
- tokens << [string_content, :content]
119
- string_content = ''
120
- end
121
- kind = :char
122
- elsif match = scan(/ \\ . /mox)
123
- string_content << match
124
- next
125
- elsif scan(/ \\ | $ /x)
126
- unless string_content.empty?
127
- tokens << [string_content, :content]
128
- string_content = ''
129
- end
130
- kind = :error
131
- state = :initial
132
- else
133
- raise "else case \" reached; %p not handled." % peek(1), tokens
134
- end
135
-
136
- else
137
- raise 'else-case reached', tokens
138
-
139
- end
140
-
141
- match ||= matched
142
- # raise [match, kind], tokens if kind == :error
143
-
144
- tokens << [match, kind]
145
-
146
- end
147
- # RAILS_DEFAULT_LOGGER.info tokens.inspect
148
- tokens
149
-
150
- end
151
-
152
- end
153
-
154
- end end