sub
format_content_order { 14 }
sub
format_content {
my
(
$class
,
$content
) =
@_
;
my
(
$in_log
,
%nicks
,
$longline
,
@newlines
);
my
@lines
=
split
( /\n/,
$$content
);
$$content
=
""
;
my
$start_re
=
$class
->gen_re(
qr/irc/
);
my
$end_re
=
$class
->gen_re(
qr/end/
);
foreach
my
$line
(
@lines
) {
if
(
$in_log
) {
if
(
$line
=~
$end_re
) {
$in_log
= 0;
if
(
$longline
) {
$longline
.=
"</dd>"
;
push
(
@newlines
,
$longline
);
$longline
=
""
;
}
push
@newlines
,
$line
;
}
elsif
(
$line
=~ /^[\d:]*\s*<[+\%\@ ]?(.*?)>\s*(.*)/ ) {
if
(
$longline
) {
$longline
.=
"</dd>"
;
push
(
@newlines
,
$longline
);
$longline
=
""
;
}
$nicks
{$1} = 1;
$longline
=
"<dt>$1</dt>\n<dd>$2"
;
}
else
{
$line
=~ s/^\s*/ /;
$longline
.=
$line
;
}
}
else
{
if
(
$line
=~
$start_re
) {
push
@newlines
,
$line
;
$in_log
= 1;
}
else
{
push
(
@newlines
,
$line
);
}
}
}
foreach
my
$line
(
@newlines
) {
if
(
$in_log
) {
if
(
$line
=~
$end_re
) {
$in_log
= 0;
$$content
.=
"</dl>\n==\n"
;
}
else
{
my
$count
= 0;
my
@colours
=(
'navy'
,
'green'
,
'maroon'
,
'blue'
,
'lime'
,
'red'
,
'silver'
,
'gray'
,
'teal'
,
'olive'
,
'purple'
,
'fuchsia'
);
my
$counter
;
foreach
my
$nick
(
keys
%nicks
) {
$colour
=
$colours
[
$counter
++];
$count
+= (
$line
=~ s!(<d.>)
$nick
(</d.>)!$1<font color=
"$colour"
>[[
$nick
]]</font>$2!g );
}
$$content
.=
"$line\n"
;
}
}
else
{
if
(
$line
=~
$start_re
) {
$in_log
= 1;
$$content
.=
"==\n<dl>\n"
;
}
else
{
$$content
.=
"$line\n"
;
}
}
}
}
1;