Marek, I have a new version of Pod::Text finished using Pod::Simple (modulo figuring out the best way to support two spaces at the end of sentences in the new parsing infrastructure, which some of us are a little anal about). Unfortunately, when released this will break Pod::Usage as it stands now, since Pod::Usage assumes that Pod::Text will inherit from Pod::Select.
I came up with the following rather scary patch which will fix this problem; with this patch, Pod::Usage detects at runtime whether it is running under the Pod::Simple-based version of Pod::Text or the Pod::Parser-based one and does the right thing. It implements a very stripped down version of Pod::Select for the Pod::Simple case. Would you be willing to take this patch as part of the Pod::Parser distribution? Alternately, I could take over maintenance of Pod::Usage as part of podlators, since it relies pretty heavily on Pod::Text, but I've been pretty busy and am not sure how much time I can devote to it on an ongoing basis. Here's the tested patch. Note that it depends somewhat on the internals of the new Pod::Text, but not in ways that I think will change. --- PodParser-1.28/lib/Pod/Usage.pm.orig 2003-11-24 07:28:04.000000000 -0800 +++ PodParser-1.28/lib/Pod/Usage.pm 2004-06-08 23:09:25.000000000 -0700 @@ -531,10 +531,69 @@ my %params = @_; my $self = {%params}; bless $self, $class; - $self->initialize(); + if ($self->can('initialize')) { + $self->initialize(); + } else { + $self = $self->SUPER::new(); + %$self = (%$self, %params); + } return $self; } +sub select { + my ($self, @res) = @_; + if ($ISA[0]->can('select')) { + $self->SUPER::select(@_); + } else { + $self->{USAGE_SELECT} = [EMAIL PROTECTED]; + } +} + +# This overrides the Pod::Text method to do something very akin to what +# Pod::Select did as well as the work done below by preprocess_paragraph. +# Note that the below is very, very specific to Pod::Text. +sub _handle_element_end { + my ($self, $element) = @_; + if ($element eq 'head1') { + $$self{USAGE_HEAD1} = $$self{PENDING}[-1][1]; + $$self{PENDING}[-1][1] =~ s/^\s*SYNOPSIS\s*$/USAGE/; + } elsif ($element eq 'head2') { + $$self{USAGE_HEAD2} = $$self{PENDING}[-1][1]; + } + if ($element eq 'head1' || $element eq 'head2') { + $$self{USAGE_SKIPPING} = 1; + my $heading = $$self{USAGE_HEAD1}; + $heading .= '/' . $$self{USAGE_HEAD2} if defined $$self{USAGE_HEAD2}; + for (@{ $$self{USAGE_SELECT} }) { + if ($heading =~ /^$_\s*$/) { + $$self{USAGE_SKIPPING} = 0; + last; + } + } + + # Try to do some lowercasing instead of all-caps in headings, and use + # a colon to end all headings. + local $_ = $$self{PENDING}[-1][1]; + s{([A-Z])([A-Z]+)}{((length($2) > 2) ? $1 : lc($1)) . lc($2)}ge; + s/\s*$/:/ unless (/:\s*$/); + $_ .= "\n"; + $$self{PENDING}[-1][1] = $_; + } + if ($$self{USAGE_SKIPPING}) { + pop @{ $$self{PENDING} }; + } else { + $self->SUPER::_handle_element_end($element); + } +} + +sub start_document { + my $self = shift; + $self->SUPER::start_document(); + my $msg = $self->{USAGE_OPTIONS}->{-message} or return 1; + my $out_fh = $self->output_fh(); + print $out_fh "$msg\n"; +} + sub begin_pod { my $self = shift; $self->SUPER::begin_pod(); ## Have to call superclass -- Russ Allbery ([EMAIL PROTECTED]) <http://www.eyrie.org/~eagle/>