1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#!/usr/bin/perl -w
use strict;
#
# Not actually contributed by anybody, but people might find this useful.
#
# This is a small PERL script to convert a ChangeLog in the same format as that
# used by devtodo into HTML.
#
# DISCLAIMER: I've only been using PERL for about a week, so I'm sure there are
# much easier ways of doing some of these things.
#
sub htmlify {
s/&/&/g;
s/</</g;
s/>/>/g;
s/\n/<br>\n/g;
s/ / /g;
return $_;
}
open(CHANGELOG, "ChangeLog");
my $version = "";
my $item = "";
my $pseudotime = 0;
my $intensity = 0;
my $textcolour = sprintf("%02x%02x%02x", $intensity * 255, $intensity * 255, $intensity * 255);
my $titlecolour = sprintf("%02x%02x%02x", $intensity * 255, $intensity * 255, $intensity * 255);
while (<CHANGELOG>) {
if (/^[0-9]\.[0-9]\.[0-9]/) {
if ($item ne "") {
print "<font color=#$textcolour>$item</font>";
print "</li>\n";
$item = "";
}
if ($version ne "") {
print "</ul>\n";
$version = "";
}
$textcolour = sprintf("%02x%02x%02x", $intensity * 255, $intensity * 255, $intensity * 255);
$titlecolour = sprintf("%02x%02x%02x", $intensity * 255, $intensity * 255, $intensity * 255);
$intensity += 0.1;
if ($intensity > 1.0) { goto quit; }
print "<ul><h3><font color=#$titlecolour>Version $_</font></h3>\n";
$pseudotime++;
$version = $_;
} elsif (/^\*/) {
s/^\*\w*//;
if ($item ne "") {
print "<font color=#$textcolour>$item</font>";
print "</li>\n";
$item = "";
}
print "<li color=#$textcolour>\n";
$pseudotime++;
$item = htmlify($_);
} else {
$item .= htmlify($_);
}
}
quit:
if ($item ne "") {
print $item;
print "</li>\n";
$item = "";
}
if ($version ne "") {
print "</ul>\n";
$version = "";
}
close(CHANGELOG);
|