Avoid buffering the line containing the error
[survex.git] / doc / news2html.pl
blob230105a2f5bee831e957b730df2e305e4b2ae807
1 #!/usr/bin/perl -w
2 require 5.008;
3 use bytes;
4 use strict;
6 # run on a NEWS file
8 my $title = 'Summary of User-Visible Changes';
9 $title .= " in $ARGV[0]" if defined $ARGV[0];
11 print <<END;
12 <HTML><HEAD>
13 <TITLE>$title</TITLE>
14 <STYLE type="text/css"><!--
15 BODY, TD, CENTER, UL, OL {font-family: sans-serif;}
16 H1 {font-size: 16px;}
17 -->
18 </STYLE>
19 </HEAD><BODY BGCOLOR=white TEXT=black>
21 END
23 my $rec;
25 my $in_ul = 0;
26 my $in_li = 0;
28 while (<STDIN>) {
29 if (s/^\*\s*//) {
30 if ($in_ul == 2) {
31 if ($in_li) {
32 print "</p></li>\n";
33 $in_li = 0;
35 print "</ul></li>\n";
36 --$in_ul;
38 if (!$in_ul) {
39 print "<ul>";
40 $in_ul = 1;
42 if ($in_li) {
43 print "</p></li>";
44 $in_li = 0;
46 print "<li><p>", html($_);
47 $in_li = 1;
48 } elsif (s/^\s+\+\s+//) {
49 if (!$in_ul) {
50 print "<ul>";
51 $in_ul = 1;
53 if ($in_ul != 2) {
54 if (!$in_li) {
55 print "<li><p>";
57 print "<ul>";
58 $in_ul = 2;
59 $in_li = 0;
61 if ($in_li) {
62 print "</p></li>";
63 $in_li = 0;
65 print "<li><p>", html($_);
66 $in_li = 1;
67 } elsif (s/^[ \t]+//) {
68 print html($_);
69 } elsif (/^$/) {
70 # do nothing
71 } else {
72 if ($in_li) {
73 print "</p></li>";
74 $in_li = 0;
76 while ($in_ul) {
77 print "</ul>";
78 --$in_ul;
79 if ($in_ul) { print "</p></li>"; }
81 $_ = html($_);
82 s!(\(.*\))!<small>$1</small>!;
83 print "<h1>$_</h1>\n";
87 if ($in_li) {
88 print "</p></li>";
89 $in_li = 0;
91 while ($in_ul) {
92 print "</ul>";
93 --$in_ul;
94 if ($in_ul) { print "</p></li>"; }
97 print <<END;
98 </BODY>
99 </HTML>
102 sub html {
103 my $t = shift;
104 $t =~ s/&/&amp;/g;
105 $t =~ s/</&lt;/g;
106 $t =~ s/>/&gt;/g;
107 return $t;