-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathtransform_changelog.pl
More file actions
executable file
·38 lines (33 loc) · 983 Bytes
/
transform_changelog.pl
File metadata and controls
executable file
·38 lines (33 loc) · 983 Bytes
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
#!/usr/bin/perl
use strict;
use warnings;
my $prev_empty = 0;
while (my $line = <>) {
chomp $line;
# Check if current line is empty (no text at all, not even whitespace)
if ($line eq '') {
if (!$prev_empty) {
# First empty line in a sequence - add \newline
print "\\newline\n";
$prev_empty = 1;
}
} else {
# Reset empty line tracker
$prev_empty = 0;
}
# Rule 4: Message-Id pattern at the beginning of the line
if ($line =~ /^Message-Id: <([^>]*)>/) {
my $msg_id = $1;
$line =~ s/^Message-Id: <[^>]*>/Message-Id: <\\nolinkurl{$msg_id}>/;
# Message-Id also matches the header pattern, so add \newline
}
# Rule 1: Lines starting with Header-Name: pattern
if ($line =~ /^[A-Z][A-Za-z-]*:/) {
print "$line\\newline\n";
#do not force empty lines after trailers
$prev_empty = 1;
}
else {
print "$line\n";
}
}