1 #!/usr/bin/perl
3 die "Usage: $0 <text file> <html file> <TexInfo file>\n"
4 unless scalar @ARGV == 3;
6 my ($text, $html, $texi) = @ARGV;
8 open TEXT, "<$text" or die "Cannot open text file \"$text\"\n";
9 open HTML, ">$html" or die "Cannot create html file \"$html\"\n";
10 open TEXI, ">$texi" or die "Cannot create TexInfo file \"$texi\"\n";
12 print HTML "<html>";
14 sub analyze($) {
15 my ($line) = @_;
16 my ($htmlLine, $texiLine) = ($line, $line);
18 # command line options
19 $texiLine =~ s/ (--?[a-z-]*)/ \@option{$1}/g;
20 $htmlLine =~ s/ (--?[a-z-]*)/ <tt>$1<\/tt>/g;
22 # [Class::]function()
23 $texiLine =~ s/([^A-Za-z])(([A-Z][A-Za-z0-9]*::)?[A-Za-z0-9]+\(\))/$1\@code{$2}/g;
24 $htmlLine =~ s/([^A-Za-z])(([A-Z][A-Za-z0-9]*::)?[A-Za-z0-9]+\(\))/$1<code>$2<\/code>/g;
26 # `file'
27 $texiLine =~ s/`([A-Za-z.\/]*)'/\@file{$1}/g;
28 $htmlLine =~ s/`([A-Za-z.\/]*)'/<tt>`$1'<\/tt>/g;
30 # TS...
31 $texiLine =~ s/(^|[^A-Z])(TS[A-Za-z_*()]*)/$1\@code{$2}/g;
32 $htmlLine =~ s/(^|[^A-Z])(TS[A-Za-z_*()]*)/$1<code>$2<\/code>/g;
34 # CXXTEST_
35 $texiLine =~ s/(CXXTEST_[A-Z_]*)/\@code{$1}/g;
36 $htmlLine =~ s/(CXXTEST_[A-Z_]*)/<tt>$1<\/tt>/g;
38 return ($htmlLine, $texiLine);
39 }
41 my $line;
42 my $inRelease = 0;
43 while ( defined( $line = <TEXT> ) ) {
44 chomp $line;
45 if ( $line =~ m/^CxxTest Releases/ ) {
46 print HTML "<title>CxxTest Releases</title>\n";
47 print HTML "<h1>CxxTest Releases</h1>\n\n";
49 print TEXI "\@appendix Version history\n";
50 print TEXI "\@itemize \@bullet\n";
51 }
52 elsif ( $line =~ m/^(.*):$/ ) {
53 if ( $inRelease ) {
54 print HTML "</ul>\n\n";
55 print TEXI "\@end itemize\n";
56 }
58 print HTML "<h2>$1</h2>\n";
59 print HTML "<ul>\n";
61 print TEXI "\@item\n\@strong{$1}\n";
62 print TEXI "\@itemize \@minus\n";
64 $inRelease = 1;
65 }
66 elsif ( $line =~ m/^ - (.*)$/ ) {
67 my ($htmlLine, $texiLine) = analyze($1);
68 print HTML "<li>$htmlLine</li>\n";
69 print TEXI "\@item\n$texiLine\n";
70 }
71 }
73 if ( $inRelease ) {
74 print HTML "</ul>\n\n";
75 print TEXI "\@end itemize\n\n";
76 }
78 print HTML "</html>\n";
79 print TEXI "\@end itemize\n";
81 close TEXT or die "Error closing text file \"$text\"\n";
82 close HTML or die "Error closing html file \"$html\"\n";
83 close TEXI or die "Error closing TexInfo file \"$texi\"\n";