Russ Allbery <[EMAIL PROTECTED]> writes:

> Jon Ericson <[EMAIL PROTECTED]> writes:
> 
> > Since the footnote ID is arbitrary anyway, what's wrong with numbers?
> 
> They're hard to remember.  Is there any drawback to allowing arbitrary
> tags?  People can always use numbers if they think they look better.

I don't think there is a drawback for Pod::Text, but Pod::Latex might
have some problems.  When it comes to a "N<random text>" sequence,
does it output a "\footnote{random text}" or "\footnotemark" command?
(I am not a LaTeX expert, so I would be happy to find I am wrong.)
The solutions I considered were:

 1) two-pass formatting 

 2) differentiate between footnote text and footnote ID using a pod
 convention
 
 3) disallowing inline-style footnotes in pod

 4) forcing all LaTeX footnotes to be "\footnotemark" style

Both 1 and 3 were unacceptable to me.  I chose what I think is the
most rational convention for indicating footnote IDs.

> (Thanks for the patch!)

Below is an alternate patch that allows anything to be a footnote ID.

Jon

--- /src/podlators-1.08/lib/Pod/Text.pm Sat Feb 10 06:50:23 2001
+++ /src/podlators/lib/Pod/Text.pm      Wed Mar 14 00:29:00 2001
@@ -330,6 +330,7 @@
     elsif ($command eq 'F') { return $self->seq_f ($_) }
     elsif ($command eq 'I') { return $self->seq_i ($_) }
     elsif ($command eq 'L') { return $self->seq_l ($_) }
+    elsif ($command eq 'N') { return $self->seq_n ($_) }
     else { carp "Unknown sequence $command<$_>" }
 }
 
@@ -461,6 +462,22 @@
     $self->verbatim ($_, $line);
 }
 
+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
+}
 
 ############################################################################
 # Interior sequences
@@ -526,6 +543,35 @@
     $text;
 }
 
+sub seq_n {
+    my $self = shift;
+    push @{$self->{NOTES}}, shift;
+    return '[' . @{$self->{NOTES}} . ']';
+}
+
+sub notes {
+    my $self = shift;
+    undef $$self{FOOTNOTE};
+    if (defined $self->{NOTES}){
+       $self->output('_' x 3 . "\n"); # "___\n" doesn't work
+       for my $note (0..$#{$self->{NOTES}}) {
+           $self->output ($note + 1 . "\n");
+           for (split /\n\n/, $self->{NOTES}[$note]) {
+               if (/^\s/) {
+                   $_ = "$_\n";
+               } else {
+                   $_ = $self->reformat("$_\n");
+               }
+               $self->output ($_);
+           }
+       }
+       undef $self->{NOTES};
+    }
+};
+
+sub end_input {
+    $_[0]->notes;
+}
 
 ############################################################################
 # List handling
@@ -615,7 +661,16 @@
 }
 
 # Output text to the output device.
-sub output { $_[1] =~ tr/\01/ /; print { $_[0]->output_handle } $_[1] }
+sub output {
+    my $self = shift;
+    local $_ = shift;
+    tr/\01/ /;
+    if (defined $$self{FOOTNOTE}) {
+       $self->{NOTES}[$$self{FOOTNOTE}] .= "$_\n";
+    } else {
+       print { $self->output_handle } $_;
+    }
+}
 
 
 ############################################################################

Reply via email to