summaryrefslogtreecommitdiff
path: root/doc/texi2pod.pl
diff options
context:
space:
mode:
Diffstat (limited to 'doc/texi2pod.pl')
-rwxr-xr-xdoc/texi2pod.pl77
1 files changed, 42 insertions, 35 deletions
diff --git a/doc/texi2pod.pl b/doc/texi2pod.pl
index 96d967ba7d..697576c185 100755
--- a/doc/texi2pod.pl
+++ b/doc/texi2pod.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl
# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
@@ -23,11 +23,13 @@
# markup to Perl POD format. It's intended to be used to extract
# something suitable for a manpage from a Texinfo document.
+use warnings;
+
$output = 0;
$skipping = 0;
-%sects = ();
-@sects_sequence = ();
-$section = "";
+%chapters = ();
+@chapters_sequence = ();
+$chapter = "";
@icstack = ();
@endwstack = ();
@skstack = ();
@@ -114,18 +116,24 @@ INF: while(<$inf>) {
die "cannot open $1: $!\n";
};
- # Look for blocks surrounded by @c man begin SECTION ... @c man end.
- # This really oughta be @ifman ... @end ifman and the like, but such
- # would require rev'ing all other Texinfo translators.
- /^\@c\s+man\s+begin\s+([A-Za-z ]+)/ and $sect = $1, push (@sects_sequence, $sect), $output = 1, next;
- /^\@c\s+man\s+end/ and do {
- $sects{$sect} = "" unless exists $sects{$sect};
- $sects{$sect} .= postprocess($section);
- $section = "";
- $output = 0;
+ /^\@chapter\s+([A-Za-z ]+)/ and do {
+ # close old chapter
+ $chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name);
+
+ # start new chapter
+ $chapter_name = $1, push (@chapters_sequence, $chapter_name);
+ $chapters{$chapter_name} = "" unless exists $chapters{$chapter_name};
+ $chapter = "";
+ $output = 1;
next;
};
+ /^\@bye/ and do {
+ # close old chapter
+ $chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name);
+ last INF;
+ };
+
# handle variables
/^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do {
$defs{$1} = $2;
@@ -148,14 +156,14 @@ INF: while(<$inf>) {
# Ignore @end foo, where foo is not an operation which may
# cause us to skip, if we are presently skipping.
my $ended = $1;
- next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
+ next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|ifhtml|ifnothtml)$/;
die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
$endw = pop @endwstack;
- if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
+ if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex|ifhtml|ifnothtml)$/) {
$skipping = pop @skstack;
next;
} elsif ($ended =~ /^(?:example|smallexample|display)$/) {
@@ -188,11 +196,11 @@ INF: while(<$inf>) {
next;
};
- /^\@(ignore|menu|iftex)\b/ and do {
+ /^\@(ignore|menu|iftex|ifhtml|ifnothtml)\b/ and do {
push @endwstack, $endw;
push @skstack, $skipping;
$endw = $1;
- $skipping = 1;
+ $skipping = $endw !~ /ifnothtml/;
next;
};
@@ -209,7 +217,6 @@ INF: while(<$inf>) {
s/\@TeX\{\}/TeX/g;
s/\@pounds\{\}/\#/g;
s/\@minus(?:\{\})?/-/g;
- s/\\,/,/g;
# Now the ones that have to be replaced by special escapes
# (which will be turned back into text by unmunge())
@@ -267,7 +274,7 @@ INF: while(<$inf>) {
push @icstack, $ic;
$endw = $1;
$ic = $2;
- $ic =~ s/\@(?:samp|strong|key|gcctabopt|option|env)/B/;
+ $ic =~ s/\@(?:samp|strong|key|gcctabopt|option|env|command)/B/;
$ic =~ s/\@(?:code|kbd)/C/;
$ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
$ic =~ s/\@(?:file)/F/;
@@ -294,7 +301,7 @@ INF: while(<$inf>) {
$columns =~ s/\@tab/ : /;
$_ = " : ". $columns;
- $section =~ s/\n+\s+$//;
+ $chapter =~ s/\n+\s+$//;
};
/^\@itemx?\s*(.+)?$/ and do {
@@ -308,7 +315,7 @@ INF: while(<$inf>) {
}
};
- $section .= $shift.$_."\n";
+ $chapter .= $shift.$_."\n";
}
# End of current file.
close($inf);
@@ -317,16 +324,15 @@ $inf = pop @instack;
die "No filename or title\n" unless defined $fn && defined $tl;
-$sects{NAME} = "$fn \- $tl\n";
-$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES};
+$chapters{NAME} = "$fn \- $tl\n";
+$chapters{FOOTNOTES} .= "=back\n" if exists $chapters{FOOTNOTES};
-unshift @sects_sequence, "NAME";
-for $sect (@sects_sequence) {
- if(exists $sects{$sect}) {
- $head = $sect;
- $head =~ s/SEEALSO/SEE ALSO/;
+unshift @chapters_sequence, "NAME";
+for $chapter (@chapters_sequence) {
+ if (exists $chapters{$chapter}) {
+ $head = uc($chapter);
print "=head1 $head\n\n";
- print scalar unmunge ($sects{$sect});
+ print scalar unmunge ($chapters{$chapter});
print "\n";
}
}
@@ -371,6 +377,7 @@ sub postprocess
s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g;
s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g;
s/;\s+\@pxref\{(?:[^\}]*)\}//g;
+ s/\@ref\{(?:[^,\}]*,)(?:[^,\}]*,)([^,\}]*).*\}/$1/g;
s/\@ref\{([^\}]*)\}/$1/g;
s/\@noindent\s*//g;
s/\@refill//g;
@@ -380,7 +387,7 @@ sub postprocess
# @uref can take one, two, or three arguments, with different
# semantics each time. @url and @email are just like @uref with
# one argument, for our purposes.
- s/\@(?:uref|url|email)\{([^\},]*)\}/&lt;B<$1>&gt;/g;
+ s/\@(?:uref|url|email)\{([^\},]*),?[^\}]*\}/&lt;B<$1>&gt;/g;
s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
@@ -424,13 +431,13 @@ sub unmunge
sub add_footnote
{
- unless (exists $sects{FOOTNOTES}) {
- $sects{FOOTNOTES} = "\n=over 4\n\n";
+ unless (exists $chapters{FOOTNOTES}) {
+ $chapters{FOOTNOTES} = "\n=over 4\n\n";
}
- $sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++;
- $sects{FOOTNOTES} .= $_[0];
- $sects{FOOTNOTES} .= "\n\n";
+ $chapters{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++;
+ $chapters{FOOTNOTES} .= $_[0];
+ $chapters{FOOTNOTES} .= "\n\n";
}
# stolen from Symbol.pm