#!/usr/bin/perl # # This script is licensed under GPL (GNU General Public License) # Use it at your own risk. # # (c) Christian Boltz 2003 # # visit http://tux.boltz.de.vu to contact me or to download a new version # # Note: You have to add the ContentType header yourself! # Do this i. e. with a filter in your mail client. # A detailed manual can be found on my homepage. use strict; use warnings; # # configure this for your commit mail format (may contain RegExes) # my $diff_start = "^Index: "; my $newfile_start = "^--- NEW FILE: "; my $delfile_start = "^--- .* DELETED ---"; my $cvs_tag = "^ +Tag: "; my $mailfooter = "^-------------------------------------------------------\$|^---------------------------------------------------------------------\$"; # # internal variables # my $mailpart = 0 ; my $line = "_" ; # # pass through header # until ($line =~ /^$/) { $line = ; print $line; } &init_body; print "
";
while (defined ($line = )) {
	chomp $line;
	$line =~ s/\&/\&/g; # encode & (must be done first!)
	$line =~ s/\/\>/g; # encode >

	if ($line =~ /$diff_start/) {
		$mailpart = 1;
		style_it ("diff_start");

	} elsif ($line =~ /$newfile_start/) {
		$mailpart = 2;
		style_it ("newfile");

	} elsif ($line =~ /$delfile_start/) {
		$mailpart = 2;
		style_it ("delfile");

	} elsif ($line =~ /$mailfooter/) {
		$mailpart = 99;
	}

	if ($mailpart == 0) { #	Intro text (commit message, ...)
		$line =~ /$cvs_tag/ && style_it ("cvs_tag");
	} elsif ($mailpart == 1) { # diffs
		$line =~ /^\+/ && style_it ("line_added");
		$line =~ /^\-/ && style_it ("line_removed");
		$line =~ /^\@/ && style_it ("linenumber");
	} elsif ($mailpart == 99) { # mailing list footer
		style_it ("mailfooter");
	}

	if ($line =~ /^$/) { $line = " "; }
	if ($line !~ /^\$line"; }
	print "$line";
}
print "
\n\n"; sub style_it { my $style=shift; $line = "

$line"; } sub init_body { print << 'EOF'; EOF } # vim:ts=4