giga-fast-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/coderay-1.1.3/MIT-LICENSE +22 -0
- data/coderay-1.1.3/README_INDEX.rdoc +123 -0
- data/coderay-1.1.3/bin/coderay +215 -0
- data/coderay-1.1.3/lib/coderay/duo.rb +81 -0
- data/coderay-1.1.3/lib/coderay/encoders/_map.rb +17 -0
- data/coderay-1.1.3/lib/coderay/encoders/comment_filter.rb +25 -0
- data/coderay-1.1.3/lib/coderay/encoders/count.rb +39 -0
- data/coderay-1.1.3/lib/coderay/encoders/debug.rb +49 -0
- data/coderay-1.1.3/lib/coderay/encoders/debug_lint.rb +63 -0
- data/coderay-1.1.3/lib/coderay/encoders/div.rb +23 -0
- data/coderay-1.1.3/lib/coderay/encoders/encoder.rb +190 -0
- data/coderay-1.1.3/lib/coderay/encoders/filter.rb +58 -0
- data/coderay-1.1.3/lib/coderay/encoders/html/css.rb +65 -0
- data/coderay-1.1.3/lib/coderay/encoders/html/numbering.rb +108 -0
- data/coderay-1.1.3/lib/coderay/encoders/html/output.rb +164 -0
- data/coderay-1.1.3/lib/coderay/encoders/html.rb +333 -0
- data/coderay-1.1.3/lib/coderay/encoders/json.rb +83 -0
- data/coderay-1.1.3/lib/coderay/encoders/lines_of_code.rb +45 -0
- data/coderay-1.1.3/lib/coderay/encoders/lint.rb +59 -0
- data/coderay-1.1.3/lib/coderay/encoders/null.rb +18 -0
- data/coderay-1.1.3/lib/coderay/encoders/page.rb +24 -0
- data/coderay-1.1.3/lib/coderay/encoders/span.rb +23 -0
- data/coderay-1.1.3/lib/coderay/encoders/statistic.rb +95 -0
- data/coderay-1.1.3/lib/coderay/encoders/terminal.rb +195 -0
- data/coderay-1.1.3/lib/coderay/encoders/text.rb +46 -0
- data/coderay-1.1.3/lib/coderay/encoders/token_kind_filter.rb +111 -0
- data/coderay-1.1.3/lib/coderay/encoders/xml.rb +72 -0
- data/coderay-1.1.3/lib/coderay/encoders/yaml.rb +50 -0
- data/coderay-1.1.3/lib/coderay/encoders.rb +18 -0
- data/coderay-1.1.3/lib/coderay/for_redcloth.rb +95 -0
- data/coderay-1.1.3/lib/coderay/helpers/file_type.rb +151 -0
- data/coderay-1.1.3/lib/coderay/helpers/plugin.rb +55 -0
- data/coderay-1.1.3/lib/coderay/helpers/plugin_host.rb +221 -0
- data/coderay-1.1.3/lib/coderay/helpers/word_list.rb +72 -0
- data/coderay-1.1.3/lib/coderay/scanners/_map.rb +24 -0
- data/coderay-1.1.3/lib/coderay/scanners/c.rb +189 -0
- data/coderay-1.1.3/lib/coderay/scanners/clojure.rb +217 -0
- data/coderay-1.1.3/lib/coderay/scanners/cpp.rb +217 -0
- data/coderay-1.1.3/lib/coderay/scanners/css.rb +196 -0
- data/coderay-1.1.3/lib/coderay/scanners/debug.rb +75 -0
- data/coderay-1.1.3/lib/coderay/scanners/delphi.rb +144 -0
- data/coderay-1.1.3/lib/coderay/scanners/diff.rb +221 -0
- data/coderay-1.1.3/lib/coderay/scanners/erb.rb +81 -0
- data/coderay-1.1.3/lib/coderay/scanners/go.rb +208 -0
- data/coderay-1.1.3/lib/coderay/scanners/groovy.rb +268 -0
- data/coderay-1.1.3/lib/coderay/scanners/haml.rb +168 -0
- data/coderay-1.1.3/lib/coderay/scanners/html.rb +275 -0
- data/coderay-1.1.3/lib/coderay/scanners/java/builtin_types.rb +421 -0
- data/coderay-1.1.3/lib/coderay/scanners/java.rb +174 -0
- data/coderay-1.1.3/lib/coderay/scanners/java_script.rb +236 -0
- data/coderay-1.1.3/lib/coderay/scanners/json.rb +98 -0
- data/coderay-1.1.3/lib/coderay/scanners/lua.rb +280 -0
- data/coderay-1.1.3/lib/coderay/scanners/php.rb +527 -0
- data/coderay-1.1.3/lib/coderay/scanners/python.rb +287 -0
- data/coderay-1.1.3/lib/coderay/scanners/raydebug.rb +75 -0
- data/coderay-1.1.3/lib/coderay/scanners/ruby/patterns.rb +178 -0
- data/coderay-1.1.3/lib/coderay/scanners/ruby/string_state.rb +79 -0
- data/coderay-1.1.3/lib/coderay/scanners/ruby.rb +477 -0
- data/coderay-1.1.3/lib/coderay/scanners/sass.rb +232 -0
- data/coderay-1.1.3/lib/coderay/scanners/scanner.rb +337 -0
- data/coderay-1.1.3/lib/coderay/scanners/sql.rb +169 -0
- data/coderay-1.1.3/lib/coderay/scanners/taskpaper.rb +36 -0
- data/coderay-1.1.3/lib/coderay/scanners/text.rb +26 -0
- data/coderay-1.1.3/lib/coderay/scanners/xml.rb +17 -0
- data/coderay-1.1.3/lib/coderay/scanners/yaml.rb +140 -0
- data/coderay-1.1.3/lib/coderay/scanners.rb +27 -0
- data/coderay-1.1.3/lib/coderay/styles/_map.rb +7 -0
- data/coderay-1.1.3/lib/coderay/styles/alpha.rb +153 -0
- data/coderay-1.1.3/lib/coderay/styles/style.rb +18 -0
- data/coderay-1.1.3/lib/coderay/styles.rb +15 -0
- data/coderay-1.1.3/lib/coderay/token_kinds.rb +85 -0
- data/coderay-1.1.3/lib/coderay/tokens.rb +164 -0
- data/coderay-1.1.3/lib/coderay/tokens_proxy.rb +55 -0
- data/coderay-1.1.3/lib/coderay/version.rb +3 -0
- data/coderay-1.1.3/lib/coderay.rb +284 -0
- data/giga-fast-rb.gemspec +12 -0
- metadata +117 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
module CodeRay
|
|
2
|
+
module Scanners
|
|
3
|
+
|
|
4
|
+
# HTML Scanner
|
|
5
|
+
#
|
|
6
|
+
# Alias: +xhtml+
|
|
7
|
+
#
|
|
8
|
+
# See also: Scanners::XML
|
|
9
|
+
class HTML < Scanner
|
|
10
|
+
|
|
11
|
+
register_for :html
|
|
12
|
+
|
|
13
|
+
KINDS_NOT_LOC = [
|
|
14
|
+
:comment, :doctype, :preprocessor,
|
|
15
|
+
:tag, :attribute_name, :operator,
|
|
16
|
+
:attribute_value, :string,
|
|
17
|
+
:plain, :entity, :error,
|
|
18
|
+
] # :nodoc:
|
|
19
|
+
|
|
20
|
+
EVENT_ATTRIBUTES = %w(
|
|
21
|
+
onabort onafterprint onbeforeprint onbeforeunload onblur oncanplay
|
|
22
|
+
oncanplaythrough onchange onclick oncontextmenu oncuechange ondblclick
|
|
23
|
+
ondrag ondragdrop ondragend ondragenter ondragleave ondragover
|
|
24
|
+
ondragstart ondrop ondurationchange onemptied onended onerror onfocus
|
|
25
|
+
onformchange onforminput onhashchange oninput oninvalid onkeydown
|
|
26
|
+
onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart
|
|
27
|
+
onmessage onmousedown onmousemove onmouseout onmouseover onmouseup
|
|
28
|
+
onmousewheel onmove onoffline ononline onpagehide onpageshow onpause
|
|
29
|
+
onplay onplaying onpopstate onprogress onratechange onreadystatechange
|
|
30
|
+
onredo onreset onresize onscroll onseeked onseeking onselect onshow
|
|
31
|
+
onstalled onstorage onsubmit onsuspend ontimeupdate onundo onunload
|
|
32
|
+
onvolumechange onwaiting
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
IN_ATTRIBUTE = WordList::CaseIgnoring.new(nil).
|
|
36
|
+
add(EVENT_ATTRIBUTES, :script).
|
|
37
|
+
add(['style'], :style)
|
|
38
|
+
|
|
39
|
+
ATTR_NAME = /[\w.:-]+/ # :nodoc:
|
|
40
|
+
TAG_END = /\/?>/ # :nodoc:
|
|
41
|
+
HEX = /[0-9a-fA-F]/ # :nodoc:
|
|
42
|
+
ENTITY = /
|
|
43
|
+
&
|
|
44
|
+
(?:
|
|
45
|
+
\w+
|
|
46
|
+
|
|
|
47
|
+
\#
|
|
48
|
+
(?:
|
|
49
|
+
\d+
|
|
50
|
+
|
|
|
51
|
+
x#{HEX}+
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
;
|
|
55
|
+
/ox # :nodoc:
|
|
56
|
+
|
|
57
|
+
PLAIN_STRING_CONTENT = {
|
|
58
|
+
"'" => /[^&'>\n]+/,
|
|
59
|
+
'"' => /[^&">\n]+/,
|
|
60
|
+
} # :nodoc:
|
|
61
|
+
|
|
62
|
+
def reset
|
|
63
|
+
super
|
|
64
|
+
@state = :initial
|
|
65
|
+
@plain_string_content = nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
protected
|
|
69
|
+
|
|
70
|
+
def setup
|
|
71
|
+
@state = :initial
|
|
72
|
+
@plain_string_content = nil
|
|
73
|
+
@in_tag = nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def scan_java_script encoder, code
|
|
77
|
+
if code && !code.empty?
|
|
78
|
+
@java_script_scanner ||= Scanners::JavaScript.new '', :keep_tokens => true
|
|
79
|
+
@java_script_scanner.tokenize code, :tokens => encoder
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def scan_css encoder, code, state = [:initial]
|
|
84
|
+
if code && !code.empty?
|
|
85
|
+
@css_scanner ||= Scanners::CSS.new '', :keep_tokens => true
|
|
86
|
+
@css_scanner.tokenize code, :tokens => encoder, :state => state
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def scan_tokens encoder, options
|
|
91
|
+
state = options[:state] || @state
|
|
92
|
+
plain_string_content = @plain_string_content
|
|
93
|
+
in_tag = @in_tag
|
|
94
|
+
in_attribute = nil
|
|
95
|
+
|
|
96
|
+
encoder.begin_group :string if state == :attribute_value_string
|
|
97
|
+
|
|
98
|
+
until eos?
|
|
99
|
+
|
|
100
|
+
if state != :in_special_tag && match = scan(/\s+/m)
|
|
101
|
+
encoder.text_token match, :space
|
|
102
|
+
|
|
103
|
+
else
|
|
104
|
+
|
|
105
|
+
case state
|
|
106
|
+
|
|
107
|
+
when :initial
|
|
108
|
+
if match = scan(/<!\[CDATA\[/)
|
|
109
|
+
encoder.text_token match, :inline_delimiter
|
|
110
|
+
if match = scan(/.*?\]\]>/m)
|
|
111
|
+
encoder.text_token match[0..-4], :plain
|
|
112
|
+
encoder.text_token ']]>', :inline_delimiter
|
|
113
|
+
elsif match = scan(/.+/)
|
|
114
|
+
encoder.text_token match, :error
|
|
115
|
+
end
|
|
116
|
+
elsif match = scan(/<!--(?:.*?-->|.*)/m)
|
|
117
|
+
encoder.text_token match, :comment
|
|
118
|
+
elsif match = scan(/<!(\w+)(?:.*?>|.*)|\]>/m)
|
|
119
|
+
encoder.text_token match, :doctype
|
|
120
|
+
elsif match = scan(/<\?xml(?:.*?\?>|.*)/m)
|
|
121
|
+
encoder.text_token match, :preprocessor
|
|
122
|
+
elsif match = scan(/<\?(?:.*?\?>|.*)/m)
|
|
123
|
+
encoder.text_token match, :comment
|
|
124
|
+
elsif match = scan(/<\/[-\w.:]*>?/m)
|
|
125
|
+
in_tag = nil
|
|
126
|
+
encoder.text_token match, :tag
|
|
127
|
+
elsif match = scan(/<(?:(script|style)|[-\w.:]+)(>)?/m)
|
|
128
|
+
encoder.text_token match, :tag
|
|
129
|
+
in_tag = self[1]
|
|
130
|
+
if self[2]
|
|
131
|
+
state = :in_special_tag if in_tag
|
|
132
|
+
else
|
|
133
|
+
state = :attribute
|
|
134
|
+
end
|
|
135
|
+
elsif match = scan(/[^<>&]+/)
|
|
136
|
+
encoder.text_token match, :plain
|
|
137
|
+
elsif match = scan(/#{ENTITY}/ox)
|
|
138
|
+
encoder.text_token match, :entity
|
|
139
|
+
elsif match = scan(/[<>&]/)
|
|
140
|
+
in_tag = nil
|
|
141
|
+
encoder.text_token match, :error
|
|
142
|
+
else
|
|
143
|
+
raise_inspect '[BUG] else-case reached with state %p' % [state], encoder
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
when :attribute
|
|
147
|
+
if match = scan(/#{TAG_END}/o)
|
|
148
|
+
encoder.text_token match, :tag
|
|
149
|
+
in_attribute = nil
|
|
150
|
+
if in_tag
|
|
151
|
+
state = :in_special_tag
|
|
152
|
+
else
|
|
153
|
+
state = :initial
|
|
154
|
+
end
|
|
155
|
+
elsif match = scan(/#{ATTR_NAME}/o)
|
|
156
|
+
in_attribute = IN_ATTRIBUTE[match]
|
|
157
|
+
encoder.text_token match, :attribute_name
|
|
158
|
+
state = :attribute_equal
|
|
159
|
+
else
|
|
160
|
+
in_tag = nil
|
|
161
|
+
encoder.text_token getch, :error
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
when :attribute_equal
|
|
165
|
+
if match = scan(/=/) #/
|
|
166
|
+
encoder.text_token match, :operator
|
|
167
|
+
state = :attribute_value
|
|
168
|
+
else
|
|
169
|
+
state = :attribute
|
|
170
|
+
next
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
when :attribute_value
|
|
174
|
+
if match = scan(/#{ATTR_NAME}/o)
|
|
175
|
+
encoder.text_token match, :attribute_value
|
|
176
|
+
state = :attribute
|
|
177
|
+
elsif match = scan(/["']/)
|
|
178
|
+
if in_attribute == :script || in_attribute == :style
|
|
179
|
+
encoder.begin_group :string
|
|
180
|
+
encoder.text_token match, :delimiter
|
|
181
|
+
if scan(/javascript:[ \t]*/)
|
|
182
|
+
encoder.text_token matched, :comment
|
|
183
|
+
end
|
|
184
|
+
code = scan_until(match == '"' ? /(?="|\z)/ : /(?='|\z)/)
|
|
185
|
+
if in_attribute == :script
|
|
186
|
+
scan_java_script encoder, code
|
|
187
|
+
else
|
|
188
|
+
scan_css encoder, code, [:block]
|
|
189
|
+
end
|
|
190
|
+
match = scan(/["']/)
|
|
191
|
+
encoder.text_token match, :delimiter if match
|
|
192
|
+
encoder.end_group :string
|
|
193
|
+
state = :attribute
|
|
194
|
+
in_attribute = nil
|
|
195
|
+
else
|
|
196
|
+
encoder.begin_group :string
|
|
197
|
+
state = :attribute_value_string
|
|
198
|
+
plain_string_content = PLAIN_STRING_CONTENT[match]
|
|
199
|
+
encoder.text_token match, :delimiter
|
|
200
|
+
end
|
|
201
|
+
elsif match = scan(/#{TAG_END}/o)
|
|
202
|
+
encoder.text_token match, :tag
|
|
203
|
+
state = :initial
|
|
204
|
+
else
|
|
205
|
+
encoder.text_token getch, :error
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
when :attribute_value_string
|
|
209
|
+
if match = scan(plain_string_content)
|
|
210
|
+
encoder.text_token match, :content
|
|
211
|
+
elsif match = scan(/['"]/)
|
|
212
|
+
encoder.text_token match, :delimiter
|
|
213
|
+
encoder.end_group :string
|
|
214
|
+
state = :attribute
|
|
215
|
+
elsif match = scan(/#{ENTITY}/ox)
|
|
216
|
+
encoder.text_token match, :entity
|
|
217
|
+
elsif match = scan(/&/)
|
|
218
|
+
encoder.text_token match, :content
|
|
219
|
+
elsif match = scan(/[\n>]/)
|
|
220
|
+
encoder.end_group :string
|
|
221
|
+
state = :initial
|
|
222
|
+
encoder.text_token match, :error
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
when :in_special_tag
|
|
226
|
+
case in_tag
|
|
227
|
+
when 'script', 'style'
|
|
228
|
+
encoder.text_token match, :space if match = scan(/[ \t]*\n/)
|
|
229
|
+
if scan(/(\s*<!--)(?:(.*?)(-->)|(.*))/m)
|
|
230
|
+
code = self[2] || self[4]
|
|
231
|
+
closing = self[3]
|
|
232
|
+
encoder.text_token self[1], :comment
|
|
233
|
+
else
|
|
234
|
+
code = scan_until(/(?=(?:\n\s*)?<\/#{in_tag}>)|\z/)
|
|
235
|
+
closing = false
|
|
236
|
+
end
|
|
237
|
+
unless code.empty?
|
|
238
|
+
encoder.begin_group :inline
|
|
239
|
+
if in_tag == 'script'
|
|
240
|
+
scan_java_script encoder, code
|
|
241
|
+
else
|
|
242
|
+
scan_css encoder, code
|
|
243
|
+
end
|
|
244
|
+
encoder.end_group :inline
|
|
245
|
+
end
|
|
246
|
+
encoder.text_token closing, :comment if closing
|
|
247
|
+
state = :initial
|
|
248
|
+
else
|
|
249
|
+
raise 'unknown special tag: %p' % [in_tag]
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
else
|
|
253
|
+
raise_inspect 'Unknown state: %p' % [state], encoder
|
|
254
|
+
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
if options[:keep_state]
|
|
262
|
+
@state = state
|
|
263
|
+
@plain_string_content = plain_string_content
|
|
264
|
+
@in_tag = in_tag
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
encoder.end_group :string if state == :attribute_value_string
|
|
268
|
+
|
|
269
|
+
encoder
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
end
|
|
275
|
+
end
|