hooligan495-rcov 0.8.1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ # rcov Copyright (c) 2004-2006 Mauricio Fernandez <mfp@acm.org>
2
+ #
3
+ # See LEGAL and LICENSE for licensing information.
4
+
5
+ module Rcov
6
+
7
+ VERSION = "0.8.1.3"
8
+ RELEASE_DATE = "2008-08-29"
9
+ RCOVRT_ABI = [2,0,0]
10
+ UPSTREAM_URL = "http://eigenclass.org/hiki/rcov"
11
+
12
+ end
13
+ # vi: set sw=2:
@@ -0,0 +1,761 @@
1
+ # xx can be redistributed and used under the following conditions
2
+ # (just keep the following copyright notice, list of conditions and disclaimer
3
+ # in order to satisfy rcov's "Ruby license" and xx's license simultaneously).
4
+ #
5
+ #ePark Labs Public License version 1
6
+ #Copyright (c) 2005, ePark Labs, Inc. and contributors
7
+ #All rights reserved.
8
+ #
9
+ #Redistribution and use in source and binary forms, with or without modification,
10
+ #are permitted provided that the following conditions are met:
11
+ #
12
+ # 1. Redistributions of source code must retain the above copyright notice, this
13
+ # list of conditions and the following disclaimer.
14
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
15
+ # this list of conditions and the following disclaimer in the documentation
16
+ # and/or other materials provided with the distribution.
17
+ # 3. Neither the name of ePark Labs nor the names of its contributors may be
18
+ # used to endorse or promote products derived from this software without
19
+ # specific prior written permission.
20
+ #
21
+ #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ #ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ #WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ #DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25
+ #ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ #(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
+ #LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28
+ #ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ unless defined? $__xx_rb__
33
+
34
+ require "rexml/document"
35
+
36
+
37
+ module XX
38
+ #--{{{
39
+ VERSION = "0.1.0"
40
+
41
+ %w(
42
+ CRAZY_LIKE_A_HELL
43
+ PERMISSIVE
44
+ STRICT
45
+ ANY
46
+ ).each{|c| const_set c, c}
47
+
48
+ class Document
49
+ #--{{{
50
+ attr "doc"
51
+ attr "stack"
52
+ attr "size"
53
+
54
+ def initialize *a, &b
55
+ #--{{{
56
+ @doc = ::REXML::Document::new(*a, &b)
57
+ @stack = [@doc]
58
+ @size = 0
59
+ #--}}}
60
+ end
61
+ def top
62
+ #--{{{
63
+ @stack.last
64
+ #--}}}
65
+ end
66
+ def push element
67
+ #--{{{
68
+ @stack.push element
69
+ #--}}}
70
+ end
71
+ def pop
72
+ #--{{{
73
+ @stack.pop unless @stack.size == 1
74
+ #--}}}
75
+ end
76
+ def tracking_additions
77
+ #--{{{
78
+ n = @size
79
+ yield
80
+ return @size - n
81
+ #--}}}
82
+ end
83
+ def to_str port = ""
84
+ #--{{{
85
+ @doc.write port, indent=-1, transitive=false, ie_hack=true
86
+ port
87
+ #--}}}
88
+ end
89
+ alias_method "to_s", "to_str"
90
+ def pretty port = ''
91
+ #--{{{
92
+ @doc.write port, indent=2, transitive=false, ie_hack=true
93
+ port
94
+ #--}}}
95
+ end
96
+ def create element
97
+ #--{{{
98
+ push element
99
+ begin
100
+ object = nil
101
+ additions =
102
+ tracking_additions do
103
+ object = yield element if block_given?
104
+ end
105
+ if object and additions.zero?
106
+ self << object
107
+ end
108
+ ensure
109
+ pop
110
+ end
111
+ self << element
112
+ element
113
+ #--}}}
114
+ end
115
+ def << object
116
+ #--{{{
117
+ t, x = top, object
118
+
119
+ if x
120
+ case t
121
+ when ::REXML::Document
122
+
123
+ begin
124
+ t <<
125
+ case x
126
+ when ::REXML::Document
127
+ x.root || ::REXML::Text::new(x.to_s)
128
+ when ::REXML::Element
129
+ x
130
+ when ::REXML::CData
131
+ x
132
+ when ::REXML::Text
133
+ x
134
+ else # string
135
+ ::REXML::Text::new(x.to_s)
136
+ end
137
+ rescue
138
+ if t.respond_to? "root"
139
+ t = t.root
140
+ retry
141
+ else
142
+ raise
143
+ end
144
+ end
145
+
146
+ when ::REXML::Element
147
+ t <<
148
+ case x
149
+ when ::REXML::Document
150
+ x.root || ::REXML::Text::new(x.to_s)
151
+ when ::REXML::Element
152
+ x
153
+ when ::REXML::CData
154
+ #::REXML::Text::new(x.write(""))
155
+ x
156
+ when ::REXML::Text
157
+ x
158
+ else # string
159
+ ::REXML::Text::new(x.to_s)
160
+ end
161
+
162
+ when ::REXML::Text
163
+ t <<
164
+ case x
165
+ when ::REXML::Document
166
+ x.write ""
167
+ when ::REXML::Element
168
+ x.write ""
169
+ when ::REXML::CData
170
+ x.write ""
171
+ when ::REXML::Text
172
+ x.write ""
173
+ else # string
174
+ x.to_s
175
+ end
176
+
177
+ else # other - try anyhow
178
+ t <<
179
+ case x
180
+ when ::REXML::Document
181
+ x.write ""
182
+ when ::REXML::Element
183
+ x.write ""
184
+ when ::REXML::CData
185
+ x.write ""
186
+ when ::REXML::Text
187
+ x.write ""
188
+ else # string
189
+ x.to_s
190
+ end
191
+ end
192
+ end
193
+
194
+ @size += 1
195
+ self
196
+ #--}}}
197
+ end
198
+ #--}}}
199
+ end
200
+
201
+ module Markup
202
+ #--{{{
203
+ class Error < ::StandardError; end
204
+
205
+ module InstanceMethods
206
+ #--{{{
207
+ def method_missing m, *a, &b
208
+ #--{{{
209
+ m = m.to_s
210
+
211
+ tag_method, tag_name = xx_class::xx_tag_method_name m
212
+
213
+ c_method_missing = xx_class::xx_config_for "method_missing", xx_which
214
+ c_tags = xx_class::xx_config_for "tags", xx_which
215
+
216
+ pat =
217
+ case c_method_missing
218
+ when ::XX::CRAZY_LIKE_A_HELL
219
+ %r/.*/
220
+ when ::XX::PERMISSIVE
221
+ %r/_$/o
222
+ when ::XX::STRICT
223
+ %r/_$/o
224
+ else
225
+ super(m.to_sym, *a, &b)
226
+ end
227
+
228
+ super(m.to_sym, *a, &b) unless m =~ pat
229
+
230
+ if c_method_missing == ::XX::STRICT
231
+ super(m.to_sym, *a, &b) unless c_tags.include? tag_name
232
+ end
233
+
234
+ ret, defined = nil
235
+
236
+ begin
237
+ xx_class::xx_define_tmp_method tag_method
238
+ xx_class::xx_define_tag_method tag_method, tag_name
239
+ ret = send tag_method, *a, &b
240
+ defined = true
241
+ ensure
242
+ xx_class::xx_remove_tag_method tag_method unless defined
243
+ end
244
+
245
+ ret
246
+ #--}}}
247
+ end
248
+ def xx_tag_ tag_name, *a, &b
249
+ #--{{{
250
+ tag_method, tag_name = xx_class::xx_tag_method_name tag_name
251
+
252
+ ret, defined = nil
253
+
254
+ begin
255
+ xx_class::xx_define_tmp_method tag_method
256
+ xx_class::xx_define_tag_method tag_method, tag_name
257
+ ret = send tag_method, *a, &b
258
+ defined = true
259
+ ensure
260
+ xx_class::xx_remove_tag_method tag_method unless defined
261
+ end
262
+
263
+ ret
264
+ #--}}}
265
+ end
266
+ alias_method "g_", "xx_tag_"
267
+ def xx_which *argv
268
+ #--{{{
269
+ @xx_which = nil unless defined? @xx_which
270
+ if argv.empty?
271
+ @xx_which
272
+ else
273
+ xx_which = @xx_which
274
+ begin
275
+ @xx_which = argv.shift
276
+ return yield
277
+ ensure
278
+ @xx_which = xx_which
279
+ end
280
+ end
281
+ #--}}}
282
+ end
283
+ def xx_with_doc_in_effect *a, &b
284
+ #--{{{
285
+ @xx_docs ||= []
286
+ doc = ::XX::Document::new(*a)
287
+ ddoc = doc.doc
288
+ begin
289
+ @xx_docs.push doc
290
+ b.call doc if b
291
+
292
+ doctype = xx_config_for "doctype", xx_which
293
+ if doctype
294
+ unless ddoc.doctype
295
+ doctype = ::REXML::DocType::new doctype unless
296
+ ::REXML::DocType === doctype
297
+ ddoc << doctype
298
+ end
299
+ end
300
+
301
+ xmldecl = xx_config_for "xmldecl", xx_which
302
+ if xmldecl
303
+ if ddoc.xml_decl == ::REXML::XMLDecl::default
304
+ xmldecl = ::REXML::XMLDecl::new xmldecl unless
305
+ ::REXML::XMLDecl === xmldecl
306
+ ddoc << xmldecl
307
+ end
308
+ end
309
+
310
+ return doc
311
+ ensure
312
+ @xx_docs.pop
313
+ end
314
+ #--}}}
315
+ end
316
+ def xx_doc
317
+ #--{{{
318
+ @xx_docs.last rescue raise "no xx_doc in effect!"
319
+ #--}}}
320
+ end
321
+ def xx_text_ *objects, &b
322
+ #--{{{
323
+ doc = xx_doc
324
+
325
+ text =
326
+ ::REXML::Text::new("",
327
+ respect_whitespace=true, parent=nil
328
+ )
329
+
330
+ objects.each do |object|
331
+ text << object.to_s if object
332
+ end
333
+
334
+ doc.create text, &b
335
+ #--}}}
336
+ end
337
+ alias_method "text_", "xx_text_"
338
+ alias_method "t_", "xx_text_"
339
+ def xx_markup_ *objects, &b
340
+ #--{{{
341
+ doc = xx_doc
342
+
343
+ doc2 = ::REXML::Document::new ""
344
+
345
+ objects.each do |object|
346
+ (doc2.root ? doc2.root : doc2) << ::REXML::Document::new(object.to_s)
347
+ end
348
+
349
+
350
+ ret = doc.create doc2, &b
351
+ puts doc2.to_s
352
+ STDIN.gets
353
+ ret
354
+ #--}}}
355
+ end
356
+ alias_method "x_", "xx_markup_"
357
+ def xx_any_ *objects, &b
358
+ #--{{{
359
+ doc = xx_doc
360
+ nothing = %r/.^/m
361
+
362
+ text =
363
+ ::REXML::Text::new("",
364
+ respect_whitespace=true, parent=nil, raw=true, entity_filter=nil, illegal=nothing
365
+ )
366
+
367
+ objects.each do |object|
368
+ text << object.to_s if object
369
+ end
370
+
371
+ doc.create text, &b
372
+ #--}}}
373
+ end
374
+ alias_method "h_", "xx_any_"
375
+ remove_method "x_" if instance_methods.include? "x_"
376
+ alias_method "x_", "xx_any_" # supplant for now
377
+ def xx_cdata_ *objects, &b
378
+ #--{{{
379
+ doc = xx_doc
380
+
381
+ cdata = ::REXML::CData::new ""
382
+
383
+ objects.each do |object|
384
+ cdata << object.to_s if object
385
+ end
386
+
387
+ doc.create cdata, &b
388
+ #--}}}
389
+ end
390
+ alias_method "c_", "xx_cdata_"
391
+ def xx_parse_attributes string
392
+ #--{{{
393
+ string = string.to_s
394
+ tokens = string.split %r/,/o
395
+ tokens.map{|t| t.sub!(%r/[^=]+=/){|key_eq| key_eq.chop << " : "}}
396
+ xx_parse_yaml_attributes(tokens.join(','))
397
+ #--}}}
398
+ end
399
+ alias_method "att_", "xx_parse_attributes"
400
+ def xx_parse_yaml_attributes string
401
+ #--{{{
402
+ require "yaml"
403
+ string = string.to_s
404
+ string = "{" << string unless string =~ %r/^\s*[{]/o
405
+ string = string << "}" unless string =~ %r/[}]\s*$/o
406
+ obj = ::YAML::load string
407
+ raise ArgumentError, "<#{ obj.class }> not Hash!" unless Hash === obj
408
+ obj
409
+ #--}}}
410
+ end
411
+ alias_method "at_", "xx_parse_yaml_attributes"
412
+ alias_method "yat_", "xx_parse_yaml_attributes"
413
+ def xx_class
414
+ #--{{{
415
+ @xx_class ||= self.class
416
+ #--}}}
417
+ end
418
+ def xx_tag_method_name *a, &b
419
+ #--{{{
420
+ xx_class.xx_tag_method_name(*a, &b)
421
+ #--}}}
422
+ end
423
+ def xx_define_tmp_method *a, &b
424
+ #--{{{
425
+ xx_class.xx_define_tmp_methodr(*a, &b)
426
+ #--}}}
427
+ end
428
+ def xx_define_tag_method *a, &b
429
+ #--{{{
430
+ xx_class.xx_define_tag_method(*a, &b)
431
+ #--}}}
432
+ end
433
+ def xx_remove_tag_method *a, &b
434
+ #--{{{
435
+ xx_class.xx_tag_remove_method(*a, &b)
436
+ #--}}}
437
+ end
438
+ def xx_ancestors
439
+ #--{{{
440
+ raise Error, "no xx_which in effect" unless xx_which
441
+ xx_class.xx_ancestors xx_which
442
+ #--}}}
443
+ end
444
+ def xx_config
445
+ #--{{{
446
+ xx_class.xx_config
447
+ #--}}}
448
+ end
449
+ def xx_config_for *a, &b
450
+ #--{{{
451
+ xx_class.xx_config_for(*a, &b)
452
+ #--}}}
453
+ end
454
+ def xx_configure *a, &b
455
+ #--{{{
456
+ xx_class.xx_configure(*a, &b)
457
+ #--}}}
458
+ end
459
+ #--}}}
460
+ end
461
+
462
+ module ClassMethods
463
+ #--{{{
464
+ def xx_tag_method_name m
465
+ #--{{{
466
+ m = m.to_s
467
+ tag_method, tag_name = m, m.gsub(%r/_+$/, "")
468
+ [ tag_method, tag_name ]
469
+ #--}}}
470
+ end
471
+ def xx_define_tmp_method m
472
+ #--{{{
473
+ define_method(m){ raise NotImplementedError, m.to_s }
474
+ #--}}}
475
+ end
476
+ def xx_define_tag_method tag_method, tag_name = nil
477
+ #--{{{
478
+ tag_method = tag_method.to_s
479
+ tag_name ||= tag_method.gsub %r/_+$/, ""
480
+
481
+ remove_method tag_method if instance_methods.include? tag_method
482
+ module_eval <<-code, __FILE__, __LINE__+1
483
+ def #{ tag_method } *a, &b
484
+ hashes, nothashes = a.partition{|x| Hash === x}
485
+
486
+ doc = xx_doc
487
+ element = ::REXML::Element::new '#{ tag_name }'
488
+
489
+ hashes.each{|h| h.each{|k,v| element.add_attribute k.to_s, v}}
490
+ nothashes.each{|nh| element << ::REXML::Text::new(nh.to_s)}
491
+
492
+ doc.create element, &b
493
+ end
494
+ code
495
+ tag_method
496
+ #--}}}
497
+ end
498
+ def xx_remove_tag_method tag_method
499
+ #--{{{
500
+ remove_method tag_method rescue nil
501
+ #--}}}
502
+ end
503
+ def xx_ancestors xx_which = self
504
+ #--{{{
505
+ list = []
506
+ ancestors.each do |a|
507
+ list << a if a < xx_which
508
+ end
509
+ xx_which.ancestors.each do |a|
510
+ list << a if a <= Markup
511
+ end
512
+ list
513
+ #--}}}
514
+ end
515
+ def xx_config
516
+ #--{{{
517
+ @@xx_config ||= Hash::new{|h,k| h[k] = {}}
518
+ #--}}}
519
+ end
520
+ def xx_config_for key, xx_which = nil
521
+ #--{{{
522
+ key = key.to_s
523
+ xx_which ||= self
524
+ xx_ancestors(xx_which).each do |a|
525
+ if xx_config[a].has_key? key
526
+ return xx_config[a][key]
527
+ end
528
+ end
529
+ nil
530
+ #--}}}
531
+ end
532
+ def xx_configure key, value, xx_which = nil
533
+ #--{{{
534
+ key = key.to_s
535
+ xx_which ||= self
536
+ xx_config[xx_which][key] = value
537
+ #--}}}
538
+ end
539
+ #--}}}
540
+ end
541
+
542
+ extend ClassMethods
543
+ include InstanceMethods
544
+
545
+ def self::included other, *a, &b
546
+ #--{{{
547
+ ret = super
548
+ other.module_eval do
549
+ include Markup::InstanceMethods
550
+ extend Markup::ClassMethods
551
+ class << self
552
+ define_method("included", Markup::XX_MARKUP_RECURSIVE_INCLUSION_PROC)
553
+ end
554
+ end
555
+ ret
556
+ #--}}}
557
+ end
558
+ XX_MARKUP_RECURSIVE_INCLUSION_PROC = method("included").to_proc
559
+
560
+ xx_configure "method_missing", XX::PERMISSIVE
561
+ xx_configure "tags", []
562
+ xx_configure "doctype", nil
563
+ xx_configure "xmldecl", nil
564
+ #--}}}
565
+ end
566
+
567
+ module XHTML
568
+ #--{{{
569
+ include Markup
570
+ xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
571
+
572
+ def xhtml_ which = XHTML, *a, &b
573
+ #--{{{
574
+ xx_which(which) do
575
+ doc = xx_with_doc_in_effect(*a, &b)
576
+ ddoc = doc.doc
577
+ root = ddoc.root
578
+ if root and root.name and root.name =~ %r/^html$/i
579
+ if root.attribute("lang",nil).nil? or root.attribute("lang",nil).to_s.empty?
580
+ root.add_attribute "lang", "en"
581
+ end
582
+ if root.attribute("xml:lang").nil? or root.attribute("xml:lang").to_s.empty?
583
+ root.add_attribute "xml:lang", "en"
584
+ end
585
+ if root.namespace.nil? or root.namespace.to_s.empty?
586
+ root.add_namespace "http://www.w3.org/1999/xhtml"
587
+ end
588
+ end
589
+ doc
590
+ end
591
+ #--}}}
592
+ end
593
+
594
+ module Strict
595
+ #--{{{
596
+ include XHTML
597
+ xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd")
598
+ xx_configure "tags", %w(
599
+ html head body div span DOCTYPE title link meta style p
600
+ h1 h2 h3 h4 h5 h6 strong em abbr acronym address bdo blockquote cite q code
601
+ ins del dfn kbd pre samp var br a base img
602
+ area map object param ul ol li dl dt dd table
603
+ tr td th tbody thead tfoot col colgroup caption form input
604
+ textarea select option optgroup button label fieldset legend script noscript b
605
+ i tt sub sup big small hr
606
+ )
607
+ xx_configure "method_missing", ::XX::STRICT
608
+
609
+ def xhtml_ which = XHTML::Strict, *a, &b
610
+ #--{{{
611
+ super(which, *a, &b)
612
+ #--}}}
613
+ end
614
+ #--}}}
615
+ end
616
+
617
+ module Transitional
618
+ #--{{{
619
+ include XHTML
620
+ xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
621
+ def xhtml_ which = XHTML::Transitional, *a, &b
622
+ #--{{{
623
+ super(which, *a, &b)
624
+ #--}}}
625
+ end
626
+ #--}}}
627
+ end
628
+ #--}}}
629
+ end
630
+
631
+ module HTML4
632
+ #--{{{
633
+ include Markup
634
+ xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
635
+
636
+ def html4_ which = HTML4, *a, &b
637
+ #--{{{
638
+ xx_which(which){ xx_with_doc_in_effect(*a, &b) }
639
+ #--}}}
640
+ end
641
+
642
+ module Strict
643
+ #--{{{
644
+ include HTML4
645
+ xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN")
646
+ xx_configure "tags", %w(
647
+ html head body div span DOCTYPE title link meta style p
648
+ h1 h2 h3 h4 h5 h6 strong em abbr acronym address bdo blockquote cite q code
649
+ ins del dfn kbd pre samp var br a base img
650
+ area map object param ul ol li dl dt dd table
651
+ tr td th tbody thead tfoot col colgroup caption form input
652
+ textarea select option optgroup button label fieldset legend script noscript b
653
+ i tt sub sup big small hr
654
+ )
655
+ xx_configure "method_missing", ::XX::STRICT
656
+ def html4_ which = HTML4::Strict, *a, &b
657
+ #--{{{
658
+ super(which, *a, &b)
659
+ #--}}}
660
+ end
661
+ #--}}}
662
+ end
663
+
664
+ module Transitional
665
+ #--{{{
666
+ include HTML4
667
+ xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
668
+ def html4_ which = HTML4::Transitional, *a, &b
669
+ #--{{{
670
+ super(which, *a, &b)
671
+ #--}}}
672
+ end
673
+ #--}}}
674
+ end
675
+ #--}}}
676
+ end
677
+ HTML = HTML4
678
+
679
+ module XML
680
+ #--{{{
681
+ include Markup
682
+ xx_configure "xmldecl", ::REXML::XMLDecl::new
683
+
684
+ def xml_ *a, &b
685
+ #--{{{
686
+ xx_which(XML){ xx_with_doc_in_effect(*a, &b)}
687
+ #--}}}
688
+ end
689
+ #--}}}
690
+ end
691
+ #--}}}
692
+ end
693
+
694
+ $__xx_rb__ = __FILE__
695
+ end
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+ #
707
+ # simple examples - see samples/ dir for more complete examples
708
+ #
709
+
710
+ if __FILE__ == $0
711
+
712
+ class Table < ::Array
713
+ include XX::XHTML::Strict
714
+ include XX::HTML4::Strict
715
+ include XX::XML
716
+
717
+ def doc
718
+ html_{
719
+ head_{ title_{ "xhtml/html4/xml demo" } }
720
+
721
+ div_{
722
+ h_{ "< malformed html & un-escaped symbols" }
723
+ }
724
+
725
+ t_{ "escaped & text > <" }
726
+
727
+ x_{ "<any_valid> xml </any_valid>" }
728
+
729
+ div_(:style => :sweet){
730
+ em_ "this is a table"
731
+
732
+ table_(:width => 42, :height => 42){
733
+ each{|row| tr_{ row.each{|cell| td_ cell } } }
734
+ }
735
+ }
736
+
737
+ script_(:type => :dangerous){ cdata_{ "javascript" } }
738
+ }
739
+ end
740
+ def to_xhtml
741
+ xhtml_{ doc }
742
+ end
743
+ def to_html4
744
+ html4_{ doc }
745
+ end
746
+ def to_xml
747
+ xml_{ doc }
748
+ end
749
+ end
750
+
751
+ table = Table[ %w( 0 1 2 ), %w( a b c ) ]
752
+
753
+ methods = %w( to_xhtml to_html4 to_xml )
754
+
755
+ methods.each do |method|
756
+ 2.times{ puts "-" * 42 }
757
+ puts(table.send(method).pretty)
758
+ puts
759
+ end
760
+
761
+ end