line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###############################################################################
|
2
|
|
|
|
|
|
|
## ##
|
3
|
|
|
|
|
|
|
## Copyright (c) 2007 - 2011 by Dan DeBrito. ##
|
4
|
|
|
|
|
|
|
## All rights reserved. ##
|
5
|
|
|
|
|
|
|
## ##
|
6
|
|
|
|
|
|
|
## This package is free software; you can redistribute it ##
|
7
|
|
|
|
|
|
|
## and/or modify it under the same terms as Perl itself. ##
|
8
|
|
|
|
|
|
|
## ##
|
9
|
|
|
|
|
|
|
###############################################################################
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package HTML::TagTree;
|
13
|
|
|
|
|
|
|
our $AUTOLOAD;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
22726
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
17
|
1
|
|
|
1
|
|
957
|
use version;
|
|
1
|
|
|
|
|
2361
|
|
|
1
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $DOUBLE_QUOTE = '"';
|
20
|
|
|
|
|
|
|
my $SINGLE_QUOTE = "'";
|
21
|
|
|
|
|
|
|
our $VERSION = qv('1.00');
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my %preprocess_tag;
|
24
|
|
|
|
|
|
|
my %empty_tags = (
|
25
|
|
|
|
|
|
|
# Tags that should not contain content or children tags
|
26
|
|
|
|
|
|
|
br => 1,
|
27
|
|
|
|
|
|
|
input => 1,
|
28
|
|
|
|
|
|
|
);
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %tag_open_substitutions = (
|
31
|
|
|
|
|
|
|
ifie => '!--[if IE]',
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
);
|
34
|
|
|
|
|
|
|
my %tag_close_substitutions = (
|
35
|
|
|
|
|
|
|
ifie => '![endif]--',
|
36
|
|
|
|
|
|
|
);
|
37
|
|
|
|
|
|
|
my %valid_empty_tags_for_shortening = (
|
38
|
|
|
|
|
|
|
# These tags don't need a full close tag but can use abbreviated notation when empty.
|
39
|
|
|
|
|
|
|
# eg:
|
40
|
|
|
|
|
|
|
# instead of
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
area => 1,
|
43
|
|
|
|
|
|
|
base => 1,
|
44
|
|
|
|
|
|
|
br => 1,
|
45
|
|
|
|
|
|
|
canvas => 1, # HTML5
|
46
|
|
|
|
|
|
|
col => 1,
|
47
|
|
|
|
|
|
|
frame => 1,
|
48
|
|
|
|
|
|
|
hr => 1,
|
49
|
|
|
|
|
|
|
input => 1,
|
50
|
|
|
|
|
|
|
img => 1,
|
51
|
|
|
|
|
|
|
link => 1,
|
52
|
|
|
|
|
|
|
meta => 1,
|
53
|
|
|
|
|
|
|
option => 1,
|
54
|
|
|
|
|
|
|
param => 1,
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
);
|
57
|
|
|
|
|
|
|
my %valid_tags = (
|
58
|
|
|
|
|
|
|
'a' => 'Defines an anchor 3.0 3.0 STF ',
|
59
|
|
|
|
|
|
|
'abbr' => 'Defines an abbreviation 6.2 STF ',
|
60
|
|
|
|
|
|
|
'acronym' => 'Defines an acronym 6.2 4.0 STF ',
|
61
|
|
|
|
|
|
|
'address' => 'Defines an address element 4.0 4.0 STF ',
|
62
|
|
|
|
|
|
|
'applet' => 'Deprecated. Defines an applet 2.0 3.0 TF ',
|
63
|
|
|
|
|
|
|
'area' => 'Defines an area inside an image map 3.0 3.0 STF ',
|
64
|
|
|
|
|
|
|
'b' => 'Defines bold text 3.0 3.0 STF ',
|
65
|
|
|
|
|
|
|
'base' => 'Defines a base URL for all the links in a page 3.0 3.0 STF ',
|
66
|
|
|
|
|
|
|
'basefont' => 'Deprecated. Defines a base font 3.0 3.0 TF ',
|
67
|
|
|
|
|
|
|
'bdo' => 'Defines the direction of text display 6.2 5.0 STF ',
|
68
|
|
|
|
|
|
|
'big' => 'Defines big text 3.0 3.0 STF ',
|
69
|
|
|
|
|
|
|
'blockquote' => 'Defines a long quotation 3.0 3.0 STF ',
|
70
|
|
|
|
|
|
|
'body' => 'Defines the body element 3.0 3.0 STF ',
|
71
|
|
|
|
|
|
|
'br' => 'Inserts a single line break 3.0 3.0 STF ',
|
72
|
|
|
|
|
|
|
'button' => 'Defines a push button 6.2 4.0 STF ',
|
73
|
|
|
|
|
|
|
'canvas' => 'HTML5',
|
74
|
|
|
|
|
|
|
'caption' => 'Defines a table caption 3.0 3.0 STF ',
|
75
|
|
|
|
|
|
|
'center' => 'Deprecated. Defines centered text 3.0 3.0 TF ',
|
76
|
|
|
|
|
|
|
'cite' => 'Defines a citation 3.0 3.0 STF ',
|
77
|
|
|
|
|
|
|
'code' => 'Defines computer code text 3.0 3.0 STF ',
|
78
|
|
|
|
|
|
|
'col' => 'Defines attributes for table columns 3.0 STF ',
|
79
|
|
|
|
|
|
|
'colgroup' => 'Defines groups of table columns 3.0 STF ',
|
80
|
|
|
|
|
|
|
'dd' => 'Defines a definition description 3.0 3.0 STF ',
|
81
|
|
|
|
|
|
|
'del' => 'Defines deleted text 6.2 4.0 STF ',
|
82
|
|
|
|
|
|
|
'dir' => 'Deprecated. Defines a directory list 3.0 3.0 TF ',
|
83
|
|
|
|
|
|
|
'div' => 'Defines a section in a document 3.0 3.0 STF ',
|
84
|
|
|
|
|
|
|
'dfn' => 'Defines a definition term 3.0 STF ',
|
85
|
|
|
|
|
|
|
'dl' => 'Defines a definition list 3.0 3.0 STF ',
|
86
|
|
|
|
|
|
|
'dt' => 'Defines a definition term 3.0 3.0 STF ',
|
87
|
|
|
|
|
|
|
'em' => 'Defines emphasized text 3.0 3.0 STF ',
|
88
|
|
|
|
|
|
|
'fieldset' => 'Defines a fieldset 6.2 4.0 STF ',
|
89
|
|
|
|
|
|
|
'font' => 'Deprecated. Defines text font, size, and color 3.0 3.0 TF ',
|
90
|
|
|
|
|
|
|
'form' => 'Defines a form 3.0 3.0 STF ',
|
91
|
|
|
|
|
|
|
'frame' => 'Defines a sub window (a frame) 3.0 3.0 F ',
|
92
|
|
|
|
|
|
|
'frameset' => 'Defines a set of frames 3.0 3.0 F ',
|
93
|
|
|
|
|
|
|
'h1' => 'Defines header 1 to header 6 3.0 3.0 STF ',
|
94
|
|
|
|
|
|
|
'h2' => 'Defines header 1 to header 6 3.0 3.0 STF ',
|
95
|
|
|
|
|
|
|
'h3' => 'Defines header 1 to header 6 3.0 3.0 STF ',
|
96
|
|
|
|
|
|
|
'h4' => 'Defines header 1 to header 6 3.0 3.0 STF ',
|
97
|
|
|
|
|
|
|
'h5' => 'Defines header 1 to header 6 3.0 3.0 STF ',
|
98
|
|
|
|
|
|
|
'h6' => 'Defines header 1 to header 6 3.0 3.0 STF ',
|
99
|
|
|
|
|
|
|
'head' => 'Defines information about the document 3.0 3.0 STF ',
|
100
|
|
|
|
|
|
|
'hr' => 'Defines a horizontal rule 3.0 3.0 STF ',
|
101
|
|
|
|
|
|
|
'html' => 'Defines an html document 3.0 3.0 STF ',
|
102
|
|
|
|
|
|
|
'i' => 'Defines italic text 3.0 3.0 STF ',
|
103
|
|
|
|
|
|
|
'ifie' => 'unigue Tag used to define Internet Explorer specific HTML ',
|
104
|
|
|
|
|
|
|
'iframe' => 'Defines an inline sub window (frame) 6.0 4.0 TF ',
|
105
|
|
|
|
|
|
|
'img' => 'Defines an image 3.0 3.0 STF ',
|
106
|
|
|
|
|
|
|
'input' => 'Defines an input field 3.0 3.0 STF ',
|
107
|
|
|
|
|
|
|
'ins' => 'Defines inserted text 6.2 4.0 STF ',
|
108
|
|
|
|
|
|
|
'isindex' => 'Deprecated. Defines a single-line input field 3.0 3.0 TF ',
|
109
|
|
|
|
|
|
|
'kbd' => 'Defines keyboard text 3.0 3.0 STF ',
|
110
|
|
|
|
|
|
|
'label' => 'Defines a label for a form control 6.2 4.0 STF ',
|
111
|
|
|
|
|
|
|
'legend' => 'Defines a title in a fieldset 6.2 4.0 STF ',
|
112
|
|
|
|
|
|
|
'li' => 'Defines a list item 3.0 3.0 STF ',
|
113
|
|
|
|
|
|
|
'link' => 'Defines a resource reference 4.0 3.0 STF ',
|
114
|
|
|
|
|
|
|
'map' => 'Defines an image map 3.0 3.0 STF ',
|
115
|
|
|
|
|
|
|
'menu' => 'Deprecated. Defines a menu list 3.0 3.0 TF ',
|
116
|
|
|
|
|
|
|
'meta' => 'Defines meta information 3.0 3.0 STF ',
|
117
|
|
|
|
|
|
|
'noframes' => 'Defines a noframe section 3.0 3.0 TF ',
|
118
|
|
|
|
|
|
|
'noscript' => 'Defines a noscript section 3.0 3.0 STF ',
|
119
|
|
|
|
|
|
|
'object' => 'Defines an embedded object 3.0 STF ',
|
120
|
|
|
|
|
|
|
'ol' => 'Defines an ordered list 3.0 3.0 STF ',
|
121
|
|
|
|
|
|
|
'optgroup' => 'Defines an option group 6.0 6.0 STF ',
|
122
|
|
|
|
|
|
|
'option' => 'Defines an option in a drop-down list 3.0 3.0 STF ',
|
123
|
|
|
|
|
|
|
'p' => 'Defines a paragraph 3.0 3.0 STF ',
|
124
|
|
|
|
|
|
|
'param' => 'Defines a parameter for an object 3.0 3.0 STF ',
|
125
|
|
|
|
|
|
|
'pre' => 'Defines preformatted text 3.0 3.0 STF ',
|
126
|
|
|
|
|
|
|
'q' => 'Defines a short quotation 6.2 STF ',
|
127
|
|
|
|
|
|
|
's' => 'Deprecated. Defines strikethrough text 3.0 3.0 TF ',
|
128
|
|
|
|
|
|
|
'samp' => 'Defines sample computer code 3.0 3.0 STF ',
|
129
|
|
|
|
|
|
|
'script' => 'Defines a script 3.0 3.0 STF ',
|
130
|
|
|
|
|
|
|
'select' => 'Defines a selectable list 3.0 3.0 STF ',
|
131
|
|
|
|
|
|
|
'small' => 'Defines small text 3.0 3.0 STF ',
|
132
|
|
|
|
|
|
|
'span' => 'Defines a section in a document 4.0 3.0 STF ',
|
133
|
|
|
|
|
|
|
'strike' => 'Deprecated. Defines strikethrough text 3.0 3.0 TF ',
|
134
|
|
|
|
|
|
|
'strong' => 'Defines strong text 3.0 3.0 STF ',
|
135
|
|
|
|
|
|
|
'style' => 'Defines a style definition 4.0 3.0 STF ',
|
136
|
|
|
|
|
|
|
'sub' => 'Defines subscripted text 3.0 3.0 STF ',
|
137
|
|
|
|
|
|
|
'sup' => 'Defines superscripted text 3.0 3.0 STF ',
|
138
|
|
|
|
|
|
|
'table' => 'Defines a table 3.0 3.0 STF ',
|
139
|
|
|
|
|
|
|
'tbody' => 'Defines a table body 4.0 STF ',
|
140
|
|
|
|
|
|
|
'td' => 'Defines a table cell 3.0 3.0 STF ',
|
141
|
|
|
|
|
|
|
'textarea' => 'Defines a text area 3.0 3.0 STF ',
|
142
|
|
|
|
|
|
|
'tfoot' => 'Defines a table footer 4.0 STF ',
|
143
|
|
|
|
|
|
|
'th' => 'Defines a table header 3.0 3.0 STF ',
|
144
|
|
|
|
|
|
|
'thead' => 'Defines a table header 4.0 STF ',
|
145
|
|
|
|
|
|
|
'title' => 'Defines the document title 3.0 3.0 STF ',
|
146
|
|
|
|
|
|
|
'tr' => 'Defines a table row 3.0 3.0 STF ',
|
147
|
|
|
|
|
|
|
'tt' => 'Defines teletype text 3.0 3.0 STF ',
|
148
|
|
|
|
|
|
|
'u' => 'Deprecated. Defines underlined text 3.0 3.0 TF ',
|
149
|
|
|
|
|
|
|
'ul' => 'Defines an unordered list 3.0 3.0 STF ',
|
150
|
|
|
|
|
|
|
'var' => 'Defines a variable 3.0 3.0 STF ',
|
151
|
|
|
|
|
|
|
'xmp' => 'Deprecated. Defines preformatted text 3.0 3.0 ',
|
152
|
|
|
|
|
|
|
);
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my %element_types = (
|
155
|
|
|
|
|
|
|
header => 'Valid header elements: |