Skip Menu |

This queue is for tickets about the Perl6-Perldoc CPAN distribution.

Report information
The Basics
Id: 46917
Status: open
Priority: 0/
Queue: Perl6-Perldoc

People
Owner: Nobody in particular
Requestors: JSTROM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: v0.0.5
Fixed in: (no value)



Subject: X<> does not populate entries w/o a separate index term
When an X<> formatting code only contains a single entry to be used for both the index term and displayed text, the entries method returns an empty list. The following code demonstrates the error: #---------------------------------------- use Perl6::Perldoc::Parser; $result = Perl6::Perldoc::Parser->parse( \'X<index term>', { all_pod => 1 } ); $tree = $result->{tree}; $POD = $tree->content; $para = $POD->content; $xform = $para->content; print "Entries: ", $xform->entries; #---------------------------------------- As a temporary solution, I'm copying the value of $data_ref->{content} to $data_ref->{entries} when $data_ref->{target} is undef in the constructor. However this fails to solve the problem for input like X<cafE<eacute>>. This is using version 0.0.5 of Perl6::Perldoc.
Subject: Re: [rt.cpan.org #46917] X<> does not populate entries w/o a separate index term
Date: Sun, 14 Jun 2009 18:06:13 +1000
To: bug-Perl6-Perldoc [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Joseph Strom reported: Show quoted text
> When an X<> formatting code only contains a single entry to be used > for both the index term and displayed text, the entries method returns > an empty list.
Definitely a bug. For the next release, I've corrected the constructor to: # Index entries have to be extracted from the index target (or index content)... sub new { my ($classname, $data_ref) = @_; if (my $entries = delete $data_ref->{target}) { $data_ref->{entries} = [split /;/, $entries]; } else { # No target --> content is target... $data_ref->{entries} = @{ $data_ref->{content} || [] } <= 1 ? [ $data_ref->{content}[0] ] : [ [ @{ $data_ref->{content} } ] ] } return $classname->SUPER::new($data_ref); } Note that this implies that entries for compound terms such as X<cafE<eacute>> are returned as an array reference containing the raw text(s) and subformat objects. This seems to be the only reasonable solution, as it gives each formatter the right (and responsibility!) to work out how to format the entry itself. Damian