about summary refs log tree commit diff
path: root/Etc/changelog2html.pl
blob: de6877d97243edd12eb397aaa2145f0783ed270b (plain) (blame)
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
#!/usr/bin/perl -w

# This programme turns the ChangeLog into changelog.html for display
# on the website.  That lives at https://zsh.sourceforge.io/Etc/changelog.html.

my $out = "changelog.html";

open CL, "ChangeLog" or die "No ChangeLog --- run in top level directory.\n";

if (-f $out) {
    die "Will not overwrite existing $out.  Delete by hand.\n";
}

my $version;
my $changes = 0;

while (<CL>) {
    /^\d+/  and  $changes++;
    if (/version\.mk.*version\s+(\d+(\.\d+)*(-\S+)?)/i) {
	$version = $1;
	$version =~ s/\.$//;
	last;
    }
}

if (defined $version) {
    warn "Outputting changelog.html for version \"$version\".\n";
    if ($changes) {
	warn "WARNING: there are changes since this version.\n";
    }
} else {
    $version = "X.X.X";
    warn "WARNING: no version found.  Set by hand\n";
}

seek CL, 0, 0;

open NEW, ">changelog.html";

select NEW;

print <<"EOH";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>ChangeLog for zsh version $version</title>
</head>
<body>
<h1>ChangeLog for zsh version $version</h1>
<pre>
EOH

while (<CL>) {
    s/&/&amp;/g;
    s/</&lt;/g;
    s/>/&gt;/g;

    print;
}

my $now = gmtime(time);

print <<"EOH";
</pre>
<hr>
Automatically generated from ChangeLog at $now
</body>
</html>
EOH