package MojoMojo::Formatter::IRCLog; use parent qw/MojoMojo::Formatter/; =head1 NAME MojoMojo::Formatter::IRCLog - format part of content as an IRC log =head1 DESCRIPTION This formatter will format content between {{irc}} and {{end}} as an IRC log =head1 METHODS =head2 format_content_order Format order can be 1-99. The IRC log formatter runs on 14, just before the main formatter. =cut sub format_content_order { 14 } =head2 format_content Calls the formatter. Takes a ref to the content as well as the context object. =cut 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 .= ""; push( @newlines, $longline ); $longline = ""; } push @newlines, $line; } elsif ( $line =~ /^[\d:]*\s*<[+\%\@ ]?(.*?)>\s*(.*)/ ) { if ($longline) { $longline .= ""; push( @newlines, $longline ); $longline = ""; } $nicks{$1} = 1; $longline = "