| 1 | package Mail::LMLM::Render::HTML; | ||||||||||||||||||||||
| 2 | 3 | $Mail::LMLM::Render::HTML::VERSION = '0.6805'; | |||||||||||||||||||||
| 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 | |||||||||||||||||||||||
| 179 | 0 | return 0; | |||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||
| 181 | |||||||||||||||||||||||
| 182 | sub start_para | ||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||
| 184 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
start_para: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 185 | |||||||||||||||||||||||
| 186 | 0 | print {*{$self->{'out'}}}("<p>\n"); | |||||||||||||||||||||
| 187 | |||||||||||||||||||||||
| 188 | 0 | return 0; | |||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||
| 190 | |||||||||||||||||||||||
| 191 | sub end_para | ||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||
| 193 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_para: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 194 | |||||||||||||||||||||||
| 195 | 0 | print {*{$self->{'out'}}}("\n</p>\n"); | |||||||||||||||||||||
| 196 | |||||||||||||||||||||||
| 197 | 0 | return 0; | |||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||
| 199 | |||||||||||||||||||||||
| 200 | sub end_section | ||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||
| 202 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_section: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 203 | |||||||||||||||||||||||
| 204 | 0 | print {*{$self->{'out'}}}("\n\n"); | |||||||||||||||||||||
| 205 | |||||||||||||||||||||||
| 206 | 0 | return 0; | |||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||
| 208 | |||||||||||||||||||||||
| 209 | sub start_document | ||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||
| 211 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
start_document: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 212 | |||||||||||||||||||||||
| 213 | 0 | my $head_title = shift; | |||||||||||||||||||||
| 214 | |||||||||||||||||||||||
| 215 | 0 | my $body_title = shift; | |||||||||||||||||||||
| 216 | |||||||||||||||||||||||
| 217 | 0 | $head_title = _htmlize($head_title); | |||||||||||||||||||||
| 218 | |||||||||||||||||||||||
| 219 | 0 | my $o = $self->{'out'}; | |||||||||||||||||||||
| 220 | |||||||||||||||||||||||
| 221 | 0 | print {*{$o}} <<"EOF" ; | |||||||||||||||||||||
| 222 | <?xml version="1.0" encoding="iso-8859-1"?> | ||||||||||||||||||||||
| 223 | <!DOCTYPE html | ||||||||||||||||||||||
| 224 | PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||||||||||||||||||||||
| 225 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||||||||||||||||||||||
| 226 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> | ||||||||||||||||||||||
| 227 | <head> | ||||||||||||||||||||||
| 228 | <title>$head_title</title> | ||||||||||||||||||||||
| 229 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | ||||||||||||||||||||||
| 230 | <link rel="stylesheet" href="./style.css" type="text/css" /> | ||||||||||||||||||||||
| 231 | </head> | ||||||||||||||||||||||
| 232 | <body> | ||||||||||||||||||||||
| 233 | EOF | ||||||||||||||||||||||
| 234 | |||||||||||||||||||||||
| 235 | |||||||||||||||||||||||
| 236 | 0 | print {*{$o}}("<h1>"); | |||||||||||||||||||||
| 237 | |||||||||||||||||||||||
| 238 | 0 | $self->text($body_title); | |||||||||||||||||||||
| 239 | |||||||||||||||||||||||
| 240 | 0 | print {*{$o}}("</h1>\n\n"); | |||||||||||||||||||||
| 241 | |||||||||||||||||||||||
| 242 | 0 | return 0; | |||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||
| 244 | |||||||||||||||||||||||
| 245 | sub end_document | ||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||
| 247 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
end_document: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 248 | |||||||||||||||||||||||
| 249 | 0 | print {*{$self->{'out'}}}( | |||||||||||||||||||||
| 250 | "\n" . | ||||||||||||||||||||||
| 251 | "</body>\n" . | ||||||||||||||||||||||
| 252 | "</html>\n" | ||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||
| 254 | |||||||||||||||||||||||
| 255 | 0 | return 0; | |||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||
| 257 | |||||||||||||||||||||||
| 258 | sub horizontal_line | ||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||
| 260 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
horizontal_line: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 261 | |||||||||||||||||||||||
| 262 | 0 | print {*{$self->{'out'}}}("\n\n<hr />\n\n"); | |||||||||||||||||||||
| 263 | |||||||||||||||||||||||
| 264 | 0 | return 0; | |||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||
| 266 | |||||||||||||||||||||||
| 267 | 3 | 1; | |||||||||||||||||||||
| 268 | |||||||||||||||||||||||
| 269 | __END__ | ||||||||||||||||||||||