meteor 0.9.13 → 0.9.15

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.
@@ -11,43 +11,49 @@ module Meteor
11
11
  # KAIGYO_CODE = "\r?\n|\r"
12
12
  # KAIGYO_CODE = "\r\n|\n|\r"
13
13
  KAIGYO_CODE = ["\r\n", "\n", "\r"]
14
- BR = '<br>'
14
+ BR = "<br>"
15
15
 
16
16
  # @@match_tag = "br|hr|img|input|meta|base"
17
- @@match_tag = ['br', 'hr', 'img', 'input', 'meta', 'base'] #[Array] void elemets (空要素)
17
+ #[Array] void elemets (空要素)
18
+ @@match_tag = ["br", "hr", "img", "input", "meta", "base"]
18
19
  # @@match_tag_2 = "textarea|option|pre"
19
- @@match_tag_2 =['textarea', 'option', 'pre'] #[Array] elements where line breaks do not need to be converted to <br> (改行を<br>に変換する必要のない要素)
20
+ #[Array] elements where line breaks do not need to be converted to <br> (改行を<br>に変換する必要のない要素)
21
+ @@match_tag_2 = ["textarea", "option", "pre"]
20
22
 
21
- @@match_tag_sng = ['texarea', 'select', 'option', 'form', 'fieldset'] #[Array] non-nestable elements (入れ子にできない要素)
23
+ #[Array] non-nestable elements (入れ子にできない要素)
24
+ @@match_tag_sng = ["texarea", "select", "option", "form", "fieldset"]
22
25
 
23
- @@attr_logic = ['disabled', 'readonly', 'checked', 'selected', 'multiple'] #[Array] boolean elements (論理値で指定する属性)
26
+ #[Array] boolean elements (論理値で指定する属性)
27
+ @@attr_logic = ["disabled", "readonly", "checked", "selected", "multiple"]
24
28
 
25
29
  # DISABLE_ELEMENT = "input|textarea|select|optgroup"
26
- DISABLE_ELEMENT = ['input', 'textarea', 'select', 'optgroup'] #[Array] elements with the disabled attribute (disabled属性のある要素)
30
+ #[Array] elements with the disabled attribute (disabled属性のある要素)
31
+ DISABLE_ELEMENT = ["input", "textarea", "select", "optgroup"]
27
32
  # READONLY_TYPE = "text|password"
28
- READONLY_TYPE = ['text', 'password'] #[Array] the type of an input element with a readonly attribute (readonly属性のあるinput要素のタイプ)
33
+ #[Array] the type of an input element with a readonly attribute (readonly属性のあるinput要素のタイプ)
34
+ READONLY_TYPE = ["text", "password"]
29
35
 
30
- SELECTED_M = '\\sselected\\s|\\sselected$|\\sSELECTED\\s|\\sSELECTED$'
36
+ SELECTED_M = "\\sselected\\s|\\sselected$|\\sSELECTED\\s|\\sSELECTED$"
31
37
  # SELECTED_M = [' selected ',' selected',' SELECTED ',' SELECTED']
32
- SELECTED_R = 'selected\\s|selected$|SELECTED\\s|SELECTED$'
33
- CHECKED_M = '\\schecked\\s|\\schecked$|\\sCHECKED\\s|\\sCHECKED$'
38
+ SELECTED_R = "selected\\s|selected$|SELECTED\\s|SELECTED$"
39
+ CHECKED_M = "\\schecked\\s|\\schecked$|\\sCHECKED\\s|\\sCHECKED$"
34
40
  # CHECKED_M = [' checked ',' checked',' CHECKED ',' CHECKED']
35
- CHECKED_R = 'checked\\s|checked$|CHECKED\\s|CHECKED$'
36
- DISABLED_M = '\\sdisabled\\s|\\sdisabled$|\\sDISABLED\\s|\\sDISABLED$'
41
+ CHECKED_R = "checked\\s|checked$|CHECKED\\s|CHECKED$"
42
+ DISABLED_M = "\\sdisabled\\s|\\sdisabled$|\\sDISABLED\\s|\\sDISABLED$"
37
43
  # DISABLED_M = [' disabled ',' disiabled',' DISABLED ',' DISABLED']
38
- DISABLED_R = 'disabled\\s|disabled$|DISABLED\\s|DISABLED$'
39
- READONLY_M = '\\sreadonly\\s|\\sreadonly$|\\sREADONLY\\s|\\sREADONLY$'
44
+ DISABLED_R = "disabled\\s|disabled$|DISABLED\\s|DISABLED$"
45
+ READONLY_M = "\\sreadonly\\s|\\sreadonly$|\\sREADONLY\\s|\\sREADONLY$"
40
46
  # READONLY_M = [' readonly ',' readonly',' READONLY ',' READONLY']
41
- READONLY_R = 'readonly\\s|readonly$|READONLY\\s|READONLY$'
42
- MULTIPLE_M = '\\smultiple\\s|\\smultiple$|\\sMULTIPLE\\s|\\sMULTIPLE$'
47
+ READONLY_R = "readonly\\s|readonly$|READONLY\\s|READONLY$"
48
+ MULTIPLE_M = "\\smultiple\\s|\\smultiple$|\\sMULTIPLE\\s|\\sMULTIPLE$"
43
49
  # MULTIPLE_M = [' multiple ',' multiple',' MULTIPLE ',' MULTIPLE']
44
- MULTIPLE_R = 'multiple\\s|multiple$|MULTIPLE\\s|MULTIPLE$'
50
+ MULTIPLE_R = "multiple\\s|multiple$|MULTIPLE\\s|MULTIPLE$"
45
51
 
46
52
  # @@pattern_true = Regexp.new("true")
47
53
  # @@pattern_false = Regexp.new("false")
48
54
 
49
- PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt|nbsp);'
50
- GET_ATTRS_MAP2 = '\\s(disabled|readonly|checked|selected|multiple)'
55
+ PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
56
+ GET_ATTRS_MAP2 = "\\s(disabled|readonly|checked|selected|multiple)"
51
57
 
52
58
  @@pattern_selected_m = Regexp.new(SELECTED_M)
53
59
  @@pattern_selected_r = Regexp.new(SELECTED_R)
@@ -67,24 +73,24 @@ module Meteor
67
73
  # @@pattern_match_tag2 = Regexp.new(@@match_tag_2)
68
74
 
69
75
  TABLE_FOR_ESCAPE_ = {
70
- '&' => '&amp;',
71
- '"' => '&quot;',
72
- '\'' => '&apos;',
73
- '<' => '&lt;',
74
- '>' => '&gt;',
75
- ' ' => '&nbsp;',
76
+ "&" => "&amp;",
77
+ "\"" => "&quot;",
78
+ "'" => "&apos;",
79
+ "<" => "&lt;",
80
+ ">" => "&gt;",
81
+ " " => "&nbsp;"
76
82
  }
77
83
 
78
84
  TABLE_FOR_ESCAPE_CONTENT_ = {
79
- '&' => '&amp;',
80
- '"' => '&quot;',
81
- '\'' => '&apos;',
82
- '<' => '&lt;',
83
- '>' => '&gt;',
84
- ' ' => '&nbsp;',
85
- "\r\n" => '<br>',
86
- "\r" => '<br>',
87
- "\n" => '<br>',
85
+ "&" => "&amp;",
86
+ "\"" => "&quot;",
87
+ "'" => "&apos;",
88
+ "<" => "&lt;",
89
+ ">" => "&gt;",
90
+ " " => "&nbsp;",
91
+ "\r\n" => "<br>",
92
+ "\r" => "<br>",
93
+ "\n" => "<br>"
88
94
  }
89
95
 
90
96
  PATTERN_ESCAPE = "[&\"'<> ]"
@@ -104,12 +110,12 @@ module Meteor
104
110
  super()
105
111
  @doc_type = Parser::HTML4
106
112
  case args.length
107
- when ZERO
108
- # initialize_0
109
- when ONE
110
- initialize_1(args[0])
111
- else
112
- raise ArgumentError
113
+ when ZERO
114
+ # initialize_0
115
+ when ONE
116
+ initialize_1(args[0])
117
+ else
118
+ raise ArgumentError
113
119
  end
114
120
  end
115
121
 
@@ -168,21 +174,21 @@ module Meteor
168
174
  def analyze_content_type
169
175
  @error_check = false
170
176
 
171
- element_3('meta', 'http-equiv', 'Content-Type')
177
+ element_3("meta", "http-equiv", "Content-Type")
172
178
 
173
179
  if !@elm_
174
- element_3('meta', 'http-equiv', 'Content-Type')
180
+ element_3("meta", "http-equiv", "Content-Type")
175
181
  end
176
182
 
177
183
  @error_check = true
178
184
 
179
185
  if @elm_
180
- content = @elm_.attr('content')
181
- content_arr = content&.split(';')
182
- @root.content_type = content_arr&.at(0) || ''
183
- @root.charset = content_arr&.at(1)&.split('=')&.at(1) || ''
186
+ content = @elm_.attr("content")
187
+ content_arr = content&.split(";")
188
+ @root.content_type = content_arr&.at(0) || ""
189
+ @root.charset = content_arr&.at(1)&.split("=")&.at(1) || ""
184
190
  else
185
- @root.content_type = ''
191
+ @root.content_type = ""
186
192
  end
187
193
  end
188
194
 
@@ -208,12 +214,12 @@ module Meteor
208
214
  # @return [Meteor::Element] element (要素)
209
215
  #
210
216
  def element_1(name)
211
- @_name = Regexp.quote(name)
217
+ quote_name(name)
212
218
 
213
219
  # case of void element (空要素の場合(<->内容あり要素の場合))
214
220
  if is_match(@@match_tag, name)
215
221
  # void element search pattern (空要素検索用パターン)
216
- @pattern_cc = String.new('') << "<" << @_name << '(|\\s[^<>]*)>'
222
+ @pattern_cc = String.new("") << "<" << @_name << "(|\\s[^<>]*)>"
217
223
  # @pattern_cc = "<#{@_name}(|\\s[^<>]*)>"
218
224
  @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
219
225
  @res = @pattern.match(@root.document)
@@ -221,8 +227,9 @@ module Meteor
221
227
  element_without_1(name)
222
228
  else
223
229
  if @error_check
224
- puts Meteor::Exception::NoSuchElementException.new(name).message
230
+ puts(Meteor::Exception::NoSuchElementException.new(name).message)
225
231
  end
232
+
226
233
  @elm_ = nil
227
234
  end
228
235
  else
@@ -239,8 +246,9 @@ module Meteor
239
246
  element_with_1(name)
240
247
  else
241
248
  if @error_check
242
- puts Meteor::Exception::NoSuchElementException.new(name).message
249
+ puts(Meteor::Exception::NoSuchElementException.new(name).message)
243
250
  end
251
+
244
252
  @elm_ = nil
245
253
  end
246
254
  end
@@ -273,8 +281,11 @@ module Meteor
273
281
  # @return [Meteor::Element] element (要素)
274
282
  #
275
283
  def element_3(name, attr_name, attr_value, quote = true)
276
-
277
- element_quote_3(name, attr_name, attr_value) if quote
284
+ if quote
285
+ quote_element_3(name, attr_name, attr_value)
286
+ else
287
+ quote_name(name)
288
+ end
278
289
 
279
290
  # case of void element (空要素の場合(<->内容あり要素の場合))
280
291
  if is_match(@@match_tag, name)
@@ -290,8 +301,9 @@ module Meteor
290
301
  element_without_3(name)
291
302
  else
292
303
  if @error_check
293
- puts Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message
304
+ puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message)
294
305
  end
306
+
295
307
  @elm_ = nil
296
308
  end
297
309
  else
@@ -313,8 +325,9 @@ module Meteor
313
325
  element_with_3_1(name)
314
326
  else
315
327
  if @error_check
316
- puts Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message
328
+ puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message)
317
329
  end
330
+
318
331
  @elm_ = nil
319
332
  end
320
333
  end
@@ -325,7 +338,7 @@ module Meteor
325
338
  private :element_3
326
339
 
327
340
  def element_without_3(name)
328
- element_without_3_1(name, '"[^<>]*)>')
341
+ element_without_3_1(name, "\"[^<>]*)>")
329
342
  end
330
343
 
331
344
  private :element_without_3
@@ -338,7 +351,7 @@ module Meteor
338
351
  #
339
352
  def element_2(attr_name, attr_value)
340
353
 
341
- element_quote_2(attr_name, attr_value)
354
+ quote_attribute(attr_name, attr_value)
342
355
 
343
356
  # @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value
344
357
  # @pattern_cc << '"[^<>]*>'
@@ -351,8 +364,9 @@ module Meteor
351
364
  element_3(@res[1], attr_name, attr_value)
352
365
  else
353
366
  if @error_check
354
- puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
367
+ puts(Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message)
355
368
  end
369
+
356
370
  @elm_ = nil
357
371
  end
358
372
 
@@ -372,7 +386,7 @@ module Meteor
372
386
  #
373
387
  def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
374
388
 
375
- element_quote_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
389
+ quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
376
390
 
377
391
  # 空要素の場合(<->内容あり要素の場合)
378
392
  if is_match(@@match_tag, name)
@@ -392,8 +406,13 @@ module Meteor
392
406
  element_without_5(name)
393
407
  else
394
408
  if @error_check
395
- puts Meteor::Exception::NoSuchElementException.new(name, attr_name1, attr_value1, attr_name2, attr_value2).message
409
+ puts(
410
+ Meteor::Exception::NoSuchElementException
411
+ .new(name, attr_name1, attr_value1, attr_name2, attr_value2)
412
+ .message
413
+ )
396
414
  end
415
+
397
416
  @elm_ = nil
398
417
  end
399
418
  else
@@ -418,8 +437,13 @@ module Meteor
418
437
  element_with_5_1(name)
419
438
  else
420
439
  if @error_check
421
- puts Meteor::Exception::NoSuchElementException.new(name, attr_name1, attr_value1, attr_name2, attr_value2).message
440
+ puts(
441
+ Meteor::Exception::NoSuchElementException
442
+ .new(name, attr_name1, attr_value1, attr_name2, attr_value2)
443
+ .message
444
+ )
422
445
  end
446
+
423
447
  @elm_ = nil
424
448
  end
425
449
  end
@@ -430,7 +454,7 @@ module Meteor
430
454
  private :element_5
431
455
 
432
456
  def element_without_5(name)
433
- element_without_5_1(name, '")[^<>]*)>')
457
+ element_without_5_1(name, "\")[^<>]*)>")
434
458
  end
435
459
 
436
460
  private :element_without_5
@@ -445,7 +469,7 @@ module Meteor
445
469
  # @return [Meteor::Element] element (要素)
446
470
  #
447
471
  def element_4(attr_name1, attr_value1, attr_name2, attr_value2)
448
- element_quote_4(attr_name1, attr_value1, attr_name2, attr_value2)
472
+ quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
449
473
 
450
474
  # @pattern_cc = String.new('') << '<([^<>"]*)\\s([^<>]*(' << @_attr_name1 << '="' << @_attr_value1
451
475
  # @pattern_cc << '"[^<>]*' << @_attr_name2 << '="' << @_attr_value2
@@ -462,8 +486,11 @@ module Meteor
462
486
  element_5(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
463
487
  else
464
488
  if @error_check
465
- puts Meteor::Exception::NoSuchElementException.new(attr_name1, attr_value1, attr_name2, attr_value2).message
489
+ puts(
490
+ Meteor::Exception::NoSuchElementException.new(attr_name1, attr_value1, attr_name2, attr_value2).message
491
+ )
466
492
  end
493
+
467
494
  @elm_ = nil
468
495
  end
469
496
 
@@ -473,15 +500,16 @@ module Meteor
473
500
  private :element_4
474
501
 
475
502
  def edit_attrs_(elm, attr_name, attr_value)
476
- if is_match('selected', attr_name) && is_match('option', elm.name)
503
+ if is_match("selected", attr_name) && is_match("option", elm.name)
477
504
  edit_attrs_5(elm, attr_name, attr_value, @@pattern_selected_m, @@pattern_selected_r)
478
- elsif is_match('multiple', attr_name) && is_match('select', elm.name)
505
+ elsif is_match("multiple", attr_name) && is_match("select", elm.name)
479
506
  edit_attrs_5(elm, attr_name, attr_value, @@pattern_multiple_m, @@pattern_multiple_r)
480
- elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
507
+ elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
481
508
  edit_attrs_5(elm, attr_name, attr_value, @@pattern_disabled_m, @@pattern_disabled_r)
482
- elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
509
+ elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
483
510
  edit_attrs_5(elm, attr_name, attr_value, @@pattern_checked_m, @@pattern_checked_r)
484
- elsif is_match('readonly', attr_name) && (is_match('textarea', elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
511
+ elsif is_match("readonly", attr_name) &&
512
+ (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
485
513
  edit_attrs_5(elm, attr_name, attr_value, @@pattern_readonly_m, @@pattern_readonly_r)
486
514
  else
487
515
  super(elm, attr_name, attr_value)
@@ -495,37 +523,39 @@ module Meteor
495
523
  @res = match_p.match(elm.attributes)
496
524
 
497
525
  if !@res
498
- if !''.eql?(elm.attributes) && !''.eql?(elm.attributes.strip)
499
- elm.attributes = String.new('') << ' ' << elm.attributes.strip
526
+ if !"".eql?(elm.attributes) && !"".eql?(elm.attributes.strip)
527
+ elm.attributes = String.new("") << " " << elm.attributes.strip
500
528
  else
501
- elm.attributes = String.new('')
529
+ elm.attributes = String.new("")
502
530
  end
503
- elm.attributes << ' ' << attr_name
531
+
532
+ elm.attributes << " " << attr_name
504
533
  # else
505
534
  end
506
535
  elsif false.equal?(attr_value) || is_match("false", attr_value)
507
- elm.attributes.sub!(replace, '')
536
+ elm.attributes.sub!(replace, "")
508
537
  end
509
538
  end
510
539
 
511
540
  private :edit_attrs_5
512
541
 
513
542
  def edit_document_1(elm)
514
- edit_document_2(elm, '>')
543
+ edit_document_2(elm, ">")
515
544
  end
516
545
 
517
546
  private :edit_document_1
518
547
 
519
548
  def get_attr_value_(elm, attr_name)
520
- if is_match('selected', attr_name) && is_match('option', elm.name)
549
+ if is_match("selected", attr_name) && is_match("option", elm.name)
521
550
  get_attr_value_r(elm, @@pattern_selected_m)
522
- elsif is_match('multiple', attr_name) && is_match('select', elm.name)
551
+ elsif is_match("multiple", attr_name) && is_match("select", elm.name)
523
552
  get_attr_value_r(elm, @@pattern_multiple_m)
524
- elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
553
+ elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
525
554
  get_attr_value_r(elm, @@pattern_disabled_m)
526
- elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
555
+ elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
527
556
  get_attr_value_r(elm, @@pattern_checked_m)
528
- elsif is_match('readonly', attr_name) && (is_match('textarea', elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
557
+ elsif is_match("readonly", attr_name) &&
558
+ (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
529
559
  get_attr_value_r(elm, @@pattern_readonly_m)
530
560
  else
531
561
  super(elm, attr_name)
@@ -536,11 +566,12 @@ module Meteor
536
566
 
537
567
  def get_type(elm)
538
568
  if !elm.type_value
539
- elm.type_value = get_attr_value_(elm, 'type')
569
+ elm.type_value = get_attr_value_(elm, "type")
540
570
  if !elm.type_value
541
571
  elm.type_value = get_attr_value_(elm, "TYPE")
542
572
  end
543
573
  end
574
+
544
575
  elm.type_value
545
576
  end
546
577
 
@@ -606,13 +637,13 @@ module Meteor
606
637
  def remove_attrs_(elm, attr_name)
607
638
  if !is_match(@@attr_logic, attr_name)
608
639
  # attribute search pattern (属性検索用パターン)
609
- @pattern = Meteor::Core::Util::PatternCache.get(String.new('') << attr_name << '="[^"]*"\\s?')
640
+ @pattern = Meteor::Core::Util::PatternCache.get(String.new("") << attr_name << "=\"[^\"]*\"\\s?")
610
641
  # @pattern = Meteor::Core::Util::PatternCache.get("#{attr_name}=\"[^\"]*\"\\s?")
611
- elm.attributes.sub!(@pattern, '')
642
+ elm.attributes.sub!(@pattern, "")
612
643
  else
613
644
  # attribute search pattern (属性検索用パターン)
614
645
  @pattern = Meteor::Core::Util::PatternCache.get(attr_name)
615
- elm.attributes.sub!(@pattern, '')
646
+ elm.attributes.sub!(@pattern, "")
616
647
  end
617
648
  end
618
649
 
@@ -644,18 +675,18 @@ module Meteor
644
675
  # 「&」<-「&amp;」
645
676
  content.gsub(@@pattern_unescape) do
646
677
  case $1
647
- when 'amp'
648
- '&'
649
- when 'quot'
650
- '"'
651
- when 'apos'
652
- "'"
653
- when 'gt'
654
- '>'
655
- when 'lt'
656
- '<'
657
- when 'nbsp'
658
- ' '
678
+ when "amp"
679
+ "&"
680
+ when "quot"
681
+ "\""
682
+ when "apos"
683
+ "'"
684
+ when "gt"
685
+ ">"
686
+ when "lt"
687
+ "<"
688
+ when "nbsp"
689
+ " "
659
690
  end
660
691
  end
661
692
 
@@ -8,16 +8,19 @@ module Meteor
8
8
  # XHTML parser (XHTMLパーサ)
9
9
  #
10
10
  class ParserImpl < Meteor::Ml::Xhtml4::ParserImpl
11
- ATTR_LOGIC = ['disabled', 'readonly', 'checked', 'selected', 'multiple', 'required'] #[Array] 論理値で指定する属性
11
+ #[Array] 論理値で指定する属性
12
+ ATTR_LOGIC = ["disabled", "readonly", "checked", "selected", "multiple", "required"]
12
13
 
13
- DISABLE_ELEMENT = ['input', 'textarea', 'select', 'optgroup', 'fieldset'] #[Array] disabled属性のある要素
14
+ #[Array] disabled属性のある要素
15
+ DISABLE_ELEMENT = ["input", "textarea", "select", "optgroup", "fieldset"]
14
16
 
15
- REQUIRE_ELEMENT = ['input', 'textarea'] #[Array] required属性のある要素
17
+ #[Array] required属性のある要素
18
+ REQUIRE_ELEMENT = ["input", "textarea"]
16
19
 
17
- REQUIRED_M = '\\srequired="[^"]*"\\s|\\srequired="[^"]*"$'
18
- REQUIRED_M1 = '\\srequired="([^"]*)"\\s|\\srequired="([^"]*)"$'
19
- REQUIRED_R = 'required="[^"]*"'
20
- REQUIRED_U = 'required="required"'
20
+ REQUIRED_M = "\\srequired=\"[^\"]*\"\\s|\\srequired=\"[^\"]*\"$"
21
+ REQUIRED_M1 = "\\srequired=\"([^\"]*)\"\\s|\\srequired=\"([^\"]*)\"$"
22
+ REQUIRED_R = "required=\"[^\"]*\""
23
+ REQUIRED_U = "required=\"required\""
21
24
 
22
25
  @@pattern_required_m = Regexp.new(REQUIRED_M)
23
26
  @@pattern_required_m1 = Regexp.new(REQUIRED_M1)
@@ -34,12 +37,12 @@ module Meteor
34
37
  @@attr_logic = ATTR_LOGIC
35
38
  @doc_type = Parser::XHTML
36
39
  case args.length
37
- when ZERO
38
- # initialize_0
39
- when ONE
40
- initialize_1(args[0])
41
- else
42
- raise ArgumentError
40
+ when ZERO
41
+ # initialize_0
42
+ when ONE
43
+ initialize_1(args[0])
44
+ else
45
+ raise ArgumentError
43
46
  end
44
47
  end
45
48
 
@@ -71,10 +74,10 @@ module Meteor
71
74
  def analyze_content_type
72
75
  @error_check = false
73
76
 
74
- element_3('meta', 'charset', '[a-zA-Z-]+', false)
77
+ element_3("meta", "charset", "[a-zA-Z-]+", false)
75
78
 
76
79
  if !@elm_
77
- element_3('meta', 'charset', '[a-zA-Z-]+', false)
80
+ element_3("meta", "charset", "[a-zA-Z-]+", false)
78
81
  end
79
82
 
80
83
  @error_check = true
@@ -88,44 +91,45 @@ module Meteor
88
91
  @root.charset = "utf-8"
89
92
  end
90
93
 
91
- @root.content_type = ''
94
+ @root.content_type = "text/html"
92
95
  end
93
96
 
94
97
  private :analyze_content_type
95
98
 
96
99
  def edit_attrs_(elm, attr_name, attr_value)
97
- if is_match('selected', attr_name) && is_match('option', elm.name)
100
+ if is_match("selected", attr_name) && is_match("option", elm.name)
98
101
  edit_attrs_5(elm, attr_value, @@pattern_selected_m, @@pattern_selected_r, SELECTED_U)
99
- elsif is_match('multiple', attr_name) && is_match('select', elm.name)
102
+ elsif is_match("multiple", attr_name) && is_match("select", elm.name)
100
103
  edit_attrs_5(elm, attr_value, @@pattern_multiple_m, @@pattern_multiple_r, MULTIPLE_U)
101
- elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
104
+ elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
102
105
  edit_attrs_5(elm, attr_value, @@pattern_disabled_m, @@pattern_disabled_r, DISABLED_U)
103
- elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
106
+ elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
104
107
  edit_attrs_5(elm, attr_value, @@pattern_checked_m, @@pattern_checked_r, CHECKED_U)
105
- elsif is_match('readonly', attr_name) && (is_match('textarea', elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
108
+ elsif is_match("readonly", attr_name) &&
109
+ (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
106
110
  edit_attrs_5(elm, attr_value, @@pattern_readonly_m, @@pattern_readonly_r, READONLY_U)
107
- elsif is_match('required', attr_name) && is_match(REQUIRE_ELEMENT, elm.name)
111
+ elsif is_match("required", attr_name) && is_match(REQUIRE_ELEMENT, elm.name)
108
112
  edit_attrs_5(elm, attr_value, @@pattern_required_m, @@pattern_required_r, REQUIRED_U)
109
113
  else
110
114
  super(elm, attr_name, attr_value)
111
115
  end
112
-
113
116
  end
114
117
 
115
118
  private :edit_attrs_
116
119
 
117
120
  def get_attr_value_(elm, attr_name)
118
- if is_match('selected', attr_name) && is_match('option', elm.name)
121
+ if is_match("selected", attr_name) && is_match("option", elm.name)
119
122
  get_attr_value_r(elm, attr_name, @@pattern_selected_m1)
120
- elsif is_match('multiple', attr_name) && is_match('select', elm.name)
123
+ elsif is_match("multiple", attr_name) && is_match("select", elm.name)
121
124
  get_attr_value_r(elm, attr_name, @@pattern_multiple_m1)
122
- elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
125
+ elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
123
126
  get_attr_value_r(elm, attr_name, @@pattern_disabled_m1)
124
- elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
127
+ elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
125
128
  get_attr_value_r(elm, attr_name, @@pattern_checked_m1)
126
- elsif is_match('readonly', attr_name) && (is_match('textarea', elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
129
+ elsif is_match("readonly", attr_name) &&
130
+ (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
127
131
  get_attr_value_r(elm, attr_name, @@pattern_readonly_m1)
128
- elsif is_match('required', attr_name) && is_match(REQUIRE_ELEMENT, elm.name)
132
+ elsif is_match("required", attr_name) && is_match(REQUIRE_ELEMENT, elm.name)
129
133
  get_attr_value_r(elm, attr_name, @@pattern_required_m1)
130
134
  else
131
135
  super(elm, attr_name)