-
Notifications
You must be signed in to change notification settings - Fork 0
/
genMaintNotes.perl
executable file
·102 lines (95 loc) · 1.67 KB
/
genMaintNotes.perl
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl -w
print <<'EOF' ;
<a href="http://3.bp.blogspot.com/-zbY2zfS4fKE/TlgfTSTK-oI/AAAAAAAACOQ/E_0Y4408QRE/s1600/GprofileSmall.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-zbY2zfS4fKE/TlgfTSTK-oI/AAAAAAAACOQ/E_0Y4408QRE/s1600/GprofileSmall.png"></a>
<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>
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";
}
}