1 | #! /usr/bin/perl |
---|
2 | |
---|
3 | my $header = ""; |
---|
4 | my @entries = (); |
---|
5 | my $ent = ""; |
---|
6 | my $inheader = 1; |
---|
7 | for (<>) { |
---|
8 | if ($inheader) { |
---|
9 | if ($_ =~ '^Discussion') { |
---|
10 | $inheader = 0; |
---|
11 | } else { |
---|
12 | $header .= $_; |
---|
13 | } |
---|
14 | } else { |
---|
15 | next if ($_ =~ /^(\}\}\}|\{\{\{)$/); |
---|
16 | if ($_ =~ /^[A-Z][a-z][a-z] \d\d [A-Z][a-z][a-z] \d\d\d\d \d\d:\d\d:\d\d [AP]M [A-Z][A-Z][A-Z], (original submission|comment #\d+):$/) { |
---|
17 | unshift @entries, $ent; |
---|
18 | $ent = ""; |
---|
19 | } |
---|
20 | $ent .= $_; |
---|
21 | } |
---|
22 | } |
---|
23 | $ent =~ s/\A[^\n]+\n\n?(.*)\Z/Original submission:\n{{{\n\1}}}\n/sm; |
---|
24 | $ent =~ s/\t([^\n]+)\n\Z//sm; |
---|
25 | |
---|
26 | print "$header$ent"; |
---|
27 | for $ent (@entries) { |
---|
28 | my $ass = $ent =~ s/In charge of this item\.\Z//sm; |
---|
29 | my $mem = $ent =~ s/\nProject (Administrator|Member)\Z//sm; |
---|
30 | $ent =~ s/\A([^,]+), comment #(\d+):\n\n?(.*)\t([^\n]+)\n\Z/\nComment \2 by \4 at \1:\n{{{\n\3}}}\n/sm; |
---|
31 | print "$ent"; |
---|
32 | } |
---|
33 | |
---|