| 1 | package Mail::LMLM::Render::HTML; | ||||||||||||||||||||||
| 2 | 3 | $Mail::LMLM::Render::HTML::VERSION = '0.6806'; | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | |||||||||||||||||||||||
| 6 | 3 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 3 | ▶ | use Mail::LMLM::Render; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 3 | @ISA = qw(Mail::LMLM::Render); | |||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | sub initialize | ||||||||||||||||||||||
| 13 | { | ||||||||||||||||||||||
| 14 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
initialize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | 0 | my $out_file = shift; | |||||||||||||||||||||
| 17 | |||||||||||||||||||||||
| 18 | 0 | $self->{'out'} = $out_file; | |||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 0 | return 0; | |||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||
| 22 | |||||||||||||||||||||||
| 23 | sub _htmlize_onechar | ||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||
| 25 | 0 | ▶ | my $c = shift; | ||||||||||||||||||||
|
Subroutine
_htmlize_onechar: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||
| 26 | |||||||||||||||||||||||
| 27 | 0 | ▶ | if ( $c eq "<" ) | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||
| 29 | 0 | return "\<"; | |||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||
| 31 | elsif ( $c eq ">" ) | ||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||
| 33 | 0 | return "\>"; | |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||
| 35 | elsif ( $c eq '&' ) | ||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||
| 37 | 0 | return "\&"; | |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||
| 39 | elsif ( $c eq "\n" ) | ||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||
| 41 | 0 | return "<br />"; | |||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||
| 43 | else | ||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||
| 45 | 0 | return $c; | |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||
| 48 | |||||||||||||||||||||||
| 49 | sub _htmlize | ||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||
| 51 | 0 | ▶ | my $text = shift; | ||||||||||||||||||||
|
Subroutine
_htmlize: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | 0 | $text =~ s/(<|>|\&|\n)/_htmlize_onechar($1)/ge; | |||||||||||||||||||||
| 54 | |||||||||||||||||||||||
| 55 | 0 | return $text; | |||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||
| 57 | |||||||||||||||||||||||
| 58 | sub text | ||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||
| 60 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
text: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||
| 61 | |||||||||||||||||||||||
| 62 | 0 | my $text = shift; | |||||||||||||||||||||
| 63 | |||||||||||||||||||||||
| 64 | 0 | my $style; | |||||||||||||||||||||
| 65 | |||||||||||||||||||||||
| 66 | 0 | ▶ | if ( scalar(@_) ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||
| 68 | 0 | $style = shift; | |||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||
| 70 | else | ||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||
| 72 | 0 | $style = {}; | |||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||
| 74 | |||||||||||||||||||||||
| 75 | 0 | my $out = _htmlize($text); | |||||||||||||||||||||
| 76 | |||||||||||||||||||||||
| 77 | 0 | ▶ | if ( $style->{'bold'} ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||
| 79 | 0 | $out = "<b>" . $out . "</b>"; | |||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||
| 81 | 0 | ▶ | if ( $style->{'underline'} ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||
| 83 | 0 | $out = "<u>" . $out . "</u>"; | |||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||
| 85 | 0 | ▶ | if ( $style->{'italic'} ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||
| 87 | 0 | $out = "<i>" . $out . "</i>"; | |||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||
| 89 | |||||||||||||||||||||||
| 90 | 0 | print { *{ $self->{'out'} } } $out; | |||||||||||||||||||||
| 91 | |||||||||||||||||||||||
| 92 | 0 | return 0; | |||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | sub newline | ||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||
| 97 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
newline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 98 | |||||||||||||||||||||||
| 99 | 0 | print { *{ $self->{'out'} } } "<br />\n"; | |||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||
| 101 | |||||||||||||||||||||||
| 102 | sub indent_inc | ||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||
| 104 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
indent_inc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 105 | |||||||||||||||||||||||
| 106 | 0 | print { *{ $self->{'out'} } } "\n<div class=\"indent\">\n"; | |||||||||||||||||||||
| 107 | |||||||||||||||||||||||
| 108 | 0 | return 0; | |||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||
| 110 | |||||||||||||||||||||||
| 111 | sub indent_dec | ||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||
| 113 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
indent_dec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 114 | |||||||||||||||||||||||
| 115 | 0 | print { *{ $self->{'out'} } } "\n</div>\n"; | |||||||||||||||||||||
| 116 | |||||||||||||||||||||||
| 117 | 0 | return 0; | |||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||
| 119 | |||||||||||||||||||||||
| 120 | sub start_link | ||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||
| 122 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
start_link: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 123 | |||||||||||||||||||||||
| 124 | 0 | my $url = shift; | |||||||||||||||||||||
| 125 | |||||||||||||||||||||||
| 126 | 0 | print { *{ $self->{'out'} } } "<a href=\"$url\">"; | |||||||||||||||||||||
| 127 | |||||||||||||||||||||||
| 128 | 0 | return 0; | |||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||
| 130 | |||||||||||||||||||||||
| 131 | sub end_link | ||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||
| 133 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_link: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 134 | |||||||||||||||||||||||
| 135 | 0 | print { *{ $self->{'out'} } } "</a>"; | |||||||||||||||||||||
| 136 | |||||||||||||||||||||||
| 137 | 0 | return 0; | |||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||
| 139 | |||||||||||||||||||||||
| 140 | sub start_section | ||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||
| 142 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
start_section: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||
| 143 | |||||||||||||||||||||||
| 144 | 0 | my $title = shift; | |||||||||||||||||||||
| 145 | |||||||||||||||||||||||
| 146 | 0 | my $options; | |||||||||||||||||||||
| 147 | |||||||||||||||||||||||
| 148 | 0 | ▶ | if ( scalar(@_) ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||
| 150 | 0 | $options = shift; | |||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||
| 152 | else | ||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||
| 154 | 0 | $options = {}; | |||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||
| 156 | |||||||||||||||||||||||
| 157 | 0 | my $o = $self->{'out'}; | |||||||||||||||||||||
| 158 | |||||||||||||||||||||||
| 159 | 0 | my $id_attr = ""; | |||||||||||||||||||||
| 160 | 0 | ▶ | if ( exists( $options->{'id'} ) ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||
| 162 | 0 | $id_attr = " id=\"" . $options->{'id'} . "\""; | |||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||
| 164 | |||||||||||||||||||||||
| 165 | 0 | print { *{$o} } "<h2${id_attr}>"; | |||||||||||||||||||||
| 166 | 0 | ▶ | if ( exists( $options->{'title_url'} ) ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||
| 168 | 0 | print { *{$o} } "<a href=\"" . $options->{'title_url'} . "\">"; | |||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||
| 170 | 0 | $self->text($title); | |||||||||||||||||||||
| 171 | 0 | ▶ | if ( exists( $options->{'title_url'} ) ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||
| 173 | 0 | print { *{$o} } "</a>"; | |||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||
| 175 | 0 | print { *{$o} } "</h2>"; | |||||||||||||||||||||
| 176 | 0 | print { *{$o} } "\n\n"; | |||||||||||||||||||||
| 177 | |||||||||||||||||||||||
| 178 | 0 | return 0; | |||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||
| 180 | |||||||||||||||||||||||
| 181 | sub start_para | ||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||
| 183 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
start_para: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 184 | |||||||||||||||||||||||
| 185 | 0 | print { *{ $self->{'out'} } } ("<p>\n"); | |||||||||||||||||||||
| 186 | |||||||||||||||||||||||
| 187 | 0 | return 0; | |||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||
| 189 | |||||||||||||||||||||||
| 190 | sub end_para | ||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||
| 192 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_para: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 193 | |||||||||||||||||||||||
| 194 | 0 | print { *{ $self->{'out'} } } ("\n</p>\n"); | |||||||||||||||||||||
| 195 | |||||||||||||||||||||||
| 196 | 0 | return 0; | |||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||
| 198 | |||||||||||||||||||||||
| 199 | sub end_section | ||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||
| 201 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_section: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 202 | |||||||||||||||||||||||
| 203 | 0 | print { *{ $self->{'out'} } } ("\n\n"); | |||||||||||||||||||||
| 204 | |||||||||||||||||||||||
| 205 | 0 | return 0; | |||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||
| 207 | |||||||||||||||||||||||
| 208 | sub start_document | ||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||
| 210 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
start_document: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 211 | |||||||||||||||||||||||
| 212 | 0 | my $head_title = shift; | |||||||||||||||||||||
| 213 | |||||||||||||||||||||||
| 214 | 0 | my $body_title = shift; | |||||||||||||||||||||
| 215 | |||||||||||||||||||||||
| 216 | 0 | $head_title = _htmlize($head_title); | |||||||||||||||||||||
| 217 | |||||||||||||||||||||||
| 218 | 0 | my $o = $self->{'out'}; | |||||||||||||||||||||
| 219 | |||||||||||||||||||||||
| 220 | 0 | print { *{$o} } <<"EOF" ; | |||||||||||||||||||||
| 221 | <?xml version="1.0" encoding="iso-8859-1"?> | ||||||||||||||||||||||
| 222 | <!DOCTYPE html | ||||||||||||||||||||||
| 223 | PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||||||||||||||||||||||
| 224 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||||||||||||||||||||||
| 225 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> | ||||||||||||||||||||||
| 226 | <head> | ||||||||||||||||||||||
| 227 | <title>$head_title</title> | ||||||||||||||||||||||
| 228 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | ||||||||||||||||||||||
| 229 | <link rel="stylesheet" href="./style.css" type="text/css" /> | ||||||||||||||||||||||
| 230 | </head> | ||||||||||||||||||||||
| 231 | <body> | ||||||||||||||||||||||
| 232 | EOF | ||||||||||||||||||||||
| 233 | |||||||||||||||||||||||
| 234 | 0 | print { *{$o} } ("<h1>"); | |||||||||||||||||||||
| 235 | |||||||||||||||||||||||
| 236 | 0 | $self->text($body_title); | |||||||||||||||||||||
| 237 | |||||||||||||||||||||||
| 238 | 0 | print { *{$o} } ("</h1>\n\n"); | |||||||||||||||||||||
| 239 | |||||||||||||||||||||||
| 240 | 0 | return 0; | |||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||
| 242 | |||||||||||||||||||||||
| 243 | sub end_document | ||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||
| 245 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_document: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 246 | |||||||||||||||||||||||
| 247 | 0 | print { *{ $self->{'out'} } } ( "\n" . "</body>\n" . "</html>\n" ); | |||||||||||||||||||||
| 248 | |||||||||||||||||||||||
| 249 | 0 | return 0; | |||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||
| 251 | |||||||||||||||||||||||
| 252 | sub horizontal_line | ||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||
| 254 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
horizontal_line: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 255 | |||||||||||||||||||||||
| 256 | 0 | print { *{ $self->{'out'} } } ("\n\n<hr />\n\n"); | |||||||||||||||||||||
| 257 | |||||||||||||||||||||||
| 258 | 0 | return 0; | |||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||
| 260 | |||||||||||||||||||||||
| 261 | 3 | 1; | |||||||||||||||||||||
| 262 | |||||||||||||||||||||||
| 263 | __END__ | ||||||||||||||||||||||