File Coverage

blib/lib/HTML/TagTree.pm
Criterion Covered Total %
statement 149 514 28.9
branch 74 280 26.4
condition 17 33 51.5
subroutine 11 37 29.7
pod 0 25 0.0
total 251 889 28.2


line stmt bran cond sub pod time code
1             ###############################################################################
2             ## ##
3             ## Copyright (c) 2007 - 2013 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   20635 use strict;
  1         2  
  1         35  
17 1     1   720 use version;
  1         2046  
  1         7  
18            
19             my $DOUBLE_QUOTE = '"';
20             my $SINGLE_QUOTE = "'";
21             our $VERSION = qv('1.03');
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 %tags_no_autowhitespace = (
38             # Don't allow autofilling of whitespace for these tags and any children
39             'a' => 1,
40             'code' => 1,
41             'pre' => 1,
42             'samp' => 1,
43             'span' => 1,
44             'textarea' => 1,
45             );
46            
47             my %valid_empty_tags_for_shortening = (
48             # These tags don't need a full close tag but can use abbreviated notation when empty.
49             # eg:
50             #
instead of

51            
52             area => 1,
53             base => 1,
54             br => 1,
55             canvas => 1, # HTML5
56             col => 1,
57             frame => 1,
58             hr => 1,
59             input => 1,
60             img => 1,
61             link => 1,
62             meta => 1,
63             option => 1,
64             param => 1,
65            
66             );
67             my %valid_tags = (
68             'a' => 'Defines an anchor 3.0 3.0 STF ',
69             'abbr' => 'Defines an abbreviation 6.2 STF ',
70             'acronym' => 'Defines an acronym 6.2 4.0 STF ',
71             'address' => 'Defines an address element 4.0 4.0 STF ',
72             'applet' => 'Deprecated. Defines an applet 2.0 3.0 TF ',
73             'area' => 'Defines an area inside an image map 3.0 3.0 STF ',
74             'b' => 'Defines bold text 3.0 3.0 STF ',
75             'base' => 'Defines a base URL for all the links in a page 3.0 3.0 STF ',
76             'basefont' => 'Deprecated. Defines a base font 3.0 3.0 TF ',
77             'bdo' => 'Defines the direction of text display 6.2 5.0 STF ',
78             'big' => 'Defines big text 3.0 3.0 STF ',
79             'blockquote' => 'Defines a long quotation 3.0 3.0 STF ',
80             'body' => 'Defines the body element 3.0 3.0 STF ',
81             'br' => 'Inserts a single line break 3.0 3.0 STF ',
82             'button' => 'Defines a push button 6.2 4.0 STF ',
83             'canvas' => 'HTML5',
84             'caption' => 'Defines a table caption 3.0 3.0 STF ',
85             'center' => 'Deprecated. Defines centered text 3.0 3.0 TF ',
86             'cite' => 'Defines a citation 3.0 3.0 STF ',
87             'code' => 'Defines computer code text 3.0 3.0 STF ',
88             'col' => 'Defines attributes for table columns 3.0 STF ',
89             'colgroup' => 'Defines groups of table columns 3.0 STF ',
90             'dd' => 'Defines a definition description 3.0 3.0 STF ',
91             'del' => 'Defines deleted text 6.2 4.0 STF ',
92             'dir' => 'Deprecated. Defines a directory list 3.0 3.0 TF ',
93             'div' => 'Defines a section in a document 3.0 3.0 STF ',
94             'dfn' => 'Defines a definition term 3.0 STF ',
95             'dl' => 'Defines a definition list 3.0 3.0 STF ',
96             'dt' => 'Defines a definition term 3.0 3.0 STF ',
97             'em' => 'Defines emphasized text 3.0 3.0 STF ',
98             'fieldset' => 'Defines a fieldset 6.2 4.0 STF ',
99             'font' => 'Deprecated. Defines text font, size, and color 3.0 3.0 TF ',
100             'form' => 'Defines a form 3.0 3.0 STF ',
101             'frame' => 'Defines a sub window (a frame) 3.0 3.0 F ',
102             'frameset' => 'Defines a set of frames 3.0 3.0 F ',
103             'h1' => 'Defines header 1 to header 6 3.0 3.0 STF ',
104             'h2' => 'Defines header 1 to header 6 3.0 3.0 STF ',
105             'h3' => 'Defines header 1 to header 6 3.0 3.0 STF ',
106             'h4' => 'Defines header 1 to header 6 3.0 3.0 STF ',
107             'h5' => 'Defines header 1 to header 6 3.0 3.0 STF ',
108             'h6' => 'Defines header 1 to header 6 3.0 3.0 STF ',
109             'head' => 'Defines information about the document 3.0 3.0 STF ',
110             'hr' => 'Defines a horizontal rule 3.0 3.0 STF ',
111             'html' => 'Defines an html document 3.0 3.0 STF ',
112             'i' => 'Defines italic text 3.0 3.0 STF ',
113             'ifie' => 'unigue Tag used to define Internet Explorer specific HTML ',
114             'iframe' => 'Defines an inline sub window (frame) 6.0 4.0 TF ',
115             'img' => 'Defines an image 3.0 3.0 STF ',
116             'input' => 'Defines an input field 3.0 3.0 STF ',
117             'ins' => 'Defines inserted text 6.2 4.0 STF ',
118             'isindex' => 'Deprecated. Defines a single-line input field 3.0 3.0 TF ',
119             'kbd' => 'Defines keyboard text 3.0 3.0 STF ',
120             'label' => 'Defines a label for a form control 6.2 4.0 STF ',
121             'legend' => 'Defines a title in a fieldset 6.2 4.0 STF ',
122             'li' => 'Defines a list item 3.0 3.0 STF ',
123             'link' => 'Defines a resource reference 4.0 3.0 STF ',
124             'map' => 'Defines an image map 3.0 3.0 STF ',
125             'menu' => 'Deprecated. Defines a menu list 3.0 3.0 TF ',
126             'meta' => 'Defines meta information 3.0 3.0 STF ',
127             'noframes' => 'Defines a noframe section 3.0 3.0 TF ',
128             'noscript' => 'Defines a noscript section 3.0 3.0 STF ',
129             'object' => 'Defines an embedded object 3.0 STF ',
130             'ol' => 'Defines an ordered list 3.0 3.0 STF ',
131             'optgroup' => 'Defines an option group 6.0 6.0 STF ',
132             'option' => 'Defines an option in a drop-down list 3.0 3.0 STF ',
133             'p' => 'Defines a paragraph 3.0 3.0 STF ',
134             'param' => 'Defines a parameter for an object 3.0 3.0 STF ',
135             'pre' => 'Defines preformatted text 3.0 3.0 STF ',
136             'q' => 'Defines a short quotation 6.2 STF ',
137             's' => 'Deprecated. Defines strikethrough text 3.0 3.0 TF ',
138             'samp' => 'Defines sample computer code 3.0 3.0 STF ',
139             'script' => 'Defines a script 3.0 3.0 STF ',
140             'select' => 'Defines a selectable list 3.0 3.0 STF ',
141             'small' => 'Defines small text 3.0 3.0 STF ',
142             'span' => 'Defines a section in a document 4.0 3.0 STF ',
143             'strike' => 'Deprecated. Defines strikethrough text 3.0 3.0 TF ',
144             'strong' => 'Defines strong text 3.0 3.0 STF ',
145             'style' => 'Defines a style definition 4.0 3.0 STF ',
146             'sub' => 'Defines subscripted text 3.0 3.0 STF ',
147             'sup' => 'Defines superscripted text 3.0 3.0 STF ',
148             'table' => 'Defines a table 3.0 3.0 STF ',
149             'tbody' => 'Defines a table body 4.0 STF ',
150             'td' => 'Defines a table cell 3.0 3.0 STF ',
151             'textarea' => 'Defines a text area 3.0 3.0 STF ',
152             'tfoot' => 'Defines a table footer 4.0 STF ',
153             'th' => 'Defines a table header 3.0 3.0 STF ',
154             'thead' => 'Defines a table header 4.0 STF ',
155             'title' => 'Defines the document title 3.0 3.0 STF ',
156             'tr' => 'Defines a table row 3.0 3.0 STF ',
157             'tt' => 'Defines teletype text 3.0 3.0 STF ',
158             'u' => 'Deprecated. Defines underlined text 3.0 3.0 TF ',
159             'ul' => 'Defines an unordered list 3.0 3.0 STF ',
160             'var' => 'Defines a variable 3.0 3.0 STF ',
161             'xmp' => 'Deprecated. Defines preformatted text 3.0 3.0 ',
162             );
163            
164             my %element_types = (
165             header => 'Valid header elements: