3 # This does trivial (and I mean _trivial_) conversion of Texinfo
4 # markup to Perl POD format. It's intended to be used to extract
5 # something suitable for a manpage from a Texinfo document.
9 die "usage: $0 infile outfile\n" unless defined $in && defined $out;
25 /^\@end ignore/ and $ignore = 0, next;
27 /^\@c man begin ([A-Z]+)/ and $sect = $1, $output = 1, next;
28 /^\@c man end/ and do {
33 s/\@(?:dfn|var|emph|cite)\{([^\}]*)\}/I<$1>/g;
34 s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g;
35 s/\@(?:samp|strong|key)\{([^\}]*)\}/B<$1>/g;
36 s/\@file\{([^\}]*)\}/F<$1>/g;
37 s/\@(?:url|email)\{([^\}]*)\}/E<lt>C<$1>E<rt>/g;
38 s/\@[a-z]?ref\{(?:[^\}]*)\}.?//g;
39 s/\(\@p[a-z]?ref\{(?:[^\}]*)\}\).?//g;
56 /^\@(c|[a-z]+index)\b/ and next;
58 /^\@setfilename\s+([^.]+)/ and $fn = $1, next;
59 /^\@settitle\s+([^.]+)/ and $tl = $1, next;
63 /^\@ignore/ and $ignore = 1, next;
65 /^\@itemize (\@[a-z]+)/ and do {
66 push @endwstack, $endw;
75 /^\@enumerate\s+([A-Z0-9]+)/ and do {
76 push @endwstack, $endw;
83 /^\@table\s+(\@[a-z]+)/ and do {
84 push @endwstack, $endw;
87 $ic =~ s/\@(?:samp|strong|key)/B/;
88 $ic =~ s/\@(?:code|kbd)/C/;
89 $ic =~ s/\@(?:dfn|var|emph|cite)/I/;
90 $ic =~ s/\@(?:file)/F/;
95 /^\@((?:small)?example)/ and do {
96 push @endwstack, $endw;
102 /^\@end\s+([a-z]+)/ and do {
105 die "\@$endw ended by \@end $1 at line $.\n"
108 if($endw =~ /example$/)
119 $endw = pop @endwstack;
123 /^\@itemx?\s*(.+)?$/ and do {
126 $_ = "=item $ic\<$1\>\n";
131 $ic =~ y/A-Ya-y1-8/B-Zb-z2-9/;
135 $section .= $shift.$_."\n";
138 $sects{NAME
} = "$fn \- $tl\n";
140 for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT FILES
141 BUGS NOTES SEEALSO AUTHOR COPYRIGHT))
143 if(exists $sects{$sect})
146 $head =~ s/SEEALSO/SEE ALSO/;
147 print "=head1 $head\n\n";