git/genMaintNotes.perl
2011-09-28 18:12:39 -07:00

103 lines
1.4 KiB
Perl
Executable File

#!/usr/bin/perl -w
print <<'EOF' ;
<style>
div.inset {
background: #aff;
color: #888;
margin-left: 10%;
margin-top: 2em;
margin-bottom: 2em;
width: 60%;
padding: 1.2em;
}
div.inset {
color: #444;
}
div.inset a {
color: #444;
}
div.inset a:hover {
color: #00f;
}
h2 {
text-decoration: underline;
color: #888;
}
span.tt {
font-family: monospace;
}
img#ohloh-badge, img#git {
border: none;
float: right;
}
</style>
<img height="64" id="git" src="http://www.kernel.org/%7Ejunio/Kun-Wave.gif" width="64" />
EOF
sub show_links {
local ($_) = @_;
my $br = '';
for (split(/\n/, $_)) {
s/^\s*//;
s/\s*\Z//;
my $url = $_;
my $comment = $_;
$url =~ s/ .*//;
if ($url =~ /^http:/) {
print "$br<a href=\"$url\"\n>$comment</a>";
} else {
print "$br$comment";
}
$br = "<br />\n";
}
print "\n";
}
sub show_commands {
local ($_) = @_;
my $br = '';
for (split(/\n/, $_)) {
s/^\s*//;
s/\s*\Z//;
print "$br<span class=\"tt\">$_</span>";
$br = "<br />\n";
}
print "\n";
}
my $in_ul;
$/ = "";
while (<>) {
$_ =~ s/\n+$//s;
if (/^ - /) {
if (!$in_ul) {
$in_ul = 1;
print "<ul>\n";
}
s/^ - //;
print "<li>$_</li>\n";
next;
}
if ($in_ul) {
$in_ul = undef;
print "</ul>\n\n";
}
if (s/^\*\s*//) {
print "<h2>$_</h2>\n\n";
} elsif (s/^ {4,}//) {
print "<div class=\"inset\">\n";
if (/^(http|git|nntp):\/\//) {
show_links($_);
} else {
show_commands($_);
}
print "</div>\n\n";
} else {
print "<p>$_</p>\n\n";
}
}