Ticket #3137: chop-trac

File chop-trac, 879 bytes (added by ossi, 11 years ago)

for completeness, here's the script i used for the comment trail conversion.

Line 
1#! /usr/bin/perl
2
3my $header = "";
4my @entries = ();
5my $ent = "";
6my $inheader = 1;
7for (<>) {
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
26print "$header$ent";
27for $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