Here is a patch for Pod::Man that more or less mirrors the footnote
patch for Pod::Text.  I freely admit that this patch is flawed.
Specifically, the footnotes are printed at the end of the document
rather than at the bottom of the page and the footnote marks should be
different depending on whether nroff, troff or groff is used.  In
other words, I am out of my depths when it comes to *roff formatting.
Hopefully either someone else will take this up, or I will have some
time to learn *roff.

Jon

--- /src/podlators-1.08/lib/Pod/Man.pm  Sat Feb 10 06:50:22 2001
+++ /src/podlators/lib/Pod/Man.pm       Thu Mar 15 03:18:01 2001
@@ -614,6 +614,12 @@
     # Add an index entry to the list of ones waiting to be output.
     if ($command eq 'X') { push (@{ $$self{INDEX} }, $_); return '' }
 
+    if ($command eq 'N') {
+       push @{ $$self{NOTES} }, $_;
+        return bless \ ('\u\f(BS' . @{ $$self{NOTES} } . '\f(BE\d'),
+         'Pod::Man::String';
+    }
+
     # Anything else is unknown.
     carp "Unknown sequence $command<$_>";
 }
@@ -785,6 +791,22 @@
     $self->output ($_);
 }
 
+sub cmd_footnote {
+    my $self = shift;
+    local $_ = shift;
+    s/\s+$//;
+    undef $$self{FOOTNOTE}, return unless length $_;
+    my $i = 0;
+    for my $note (@{$self->{NOTES}}) {
+       if ($note eq $_) {
+           $$self{FOOTNOTE} = $i;
+           $self->{NOTES}[$i] = '';
+           return;
+       }
+       $i++;
+    }
+    $$self{FOOTNOTE} = $i; # orphan footnote case
+}
 
 ############################################################################
 # Link handling
@@ -1067,7 +1089,35 @@
 }
 
 # Output text to the output device.
-sub output { print { $_[0]->output_handle } $_[1] }
+sub output {
+    my $self = shift;
+    local $_ = shift;
+    if (defined $$self{FOOTNOTE}) {
+       $self->{NOTES}[$$self{FOOTNOTE}] .= $_;
+    } else {
+       print { $self->output_handle } $_;
+    }
+}
+
+sub notes {
+    my $self = shift;
+    undef $$self{FOOTNOTE};
+    if (defined $self->{NOTES}){
+       $self->makespace;
+       $self->output("___\n");
+       for my $note (0..$#{$self->{NOTES}}) {
+           $self->makespace;
+           $self->output ("\n" . $note + 1 . "\n");
+           $self->makespace;
+           $self->output ("$self->{NOTES}[$note]\n");
+       }
+       undef $self->{NOTES};
+    }
+};
+
+sub end_input {
+    $_[0]->notes;
+}
 
 # Given a command and a single argument that may or may not contain double
 # quotes, handle double-quote formatting for it.  If there are no double

Reply via email to