in reply to Re: creating links to an =item in the same page via pod2html
in thread creating links to an =item in the same page via pod2html

Thanks a lot for taking a look at this; if you get a change to dig more before I do, that would be wonderful.

It looks to me like the patch leaves $page false and $ident = "bar", which is exactly what the following elseif should come up with.

  • Comment on Re^2: creating links to an =item in the same page via pod2html

Replies are listed 'Best First'.
Re^3: creating links to an =item in the same page via pod2html
by themage (Friar) on Jul 01, 2005 at 22:10 UTC
    That's looks correct for me.

    They are there for two diferente ends:

    case 1: name/ident
    In this situation is expected L<page/itemname> where page can be empty (which is the case)

    case 2: name/"section name"
    In this case it is expected a sectionname, quoted. for some reason (because if there isn't a item with a given name Pod::Html will look for a section with the same name, the author (in his own comments) even though this should be a "section", we go for ident first. It works, as well as using a section name without quotes, that would in the previous case, and is treated as a ident, and then as a section if there is no ident with such name.

    case 3: something that have a space
    In this case Pod::Html assumes that we are looking for a section, as pages don't have whitespaces in names.

    case 4: everything else
    A link to anything that don't have spaces, nor a slash is a link to a page.

    I think that is missing a case, that could be managed before case 3 with:
    } elsif ($par=~m{"(.*)"}) { ($page,$section)=('',$1); #In this case, it looks to me # that the pod author forgot the initial / but is # trying to link to a section in corrent page # (quoted name).
    I'm also not seeing why the quotes in the second case are optional. Without garantees, my final patch would look like this:
    --- Html.pm 2005-07-01 14:48:23.000000000 +0100 +++ Html.pm.new 2005-07-01 23:07:35.000000000 +0100 @@ -1549,15 +1549,20 @@ my( $page, $section, $ident ); # check for link patterns - if( $par =~ m{^([^/]+?)/(?!")(.*?)$} ){ # name/ident + if( $par =~ m{^([^/]+)?/(?!")(.*?)$} ){ # name/ident # we've got a name/ident (no quotes) ( $page, $ident ) = ( $1, $2 ); ### print STDERR "--> L<$par> to page $page, ident $ident +\n"; - } elsif( $par =~ m{^(.*?)/"?(.*?)"?$} ){ # [name]/"section" - # even though this should be a "section", we go for ident + first - ( $page, $ident ) = ( $1, $2 ); + } elsif( $par =~ m{^(.*)?/"(.*?)"$} ){ # [name]/"section" + # we've got a name/"section" + ( $page, $section ) = ( $1, $2 ); ### print STDERR "--> L<$par> to page $page, section $sec +tion\n"; + + } elsif ( $par =~ m{^"(.*?)"$} ){ # "section" + # we've got a section without a pagename + ( $page, $section ) = ('',$1); + ### print STDERR "--> L<$par> to void page, section $sect +ion\n"; } elsif( $par =~ /\s/ ){ # this must be a section with missin +g quotes ( $page, $section ) = ( '', $par );
    But, maybe I'm missing something that Tom Christiansen found. I don't know.
      IIRC, the /^".*"$/ case is handled by a s!^"!/"! just before the if, which makes it fall under the firse elsif. (This code is unnecessarily byzantine.)

      As far as I can tell, the only reason for separate handling of the if clause and the first elsif would be if the second one assigned to section, as you have made it do. However, since the code didn't actually do so, I assume there was a reason... I'm a little handicapped by not knowing what an "ident" is :)

      I'll give your patch a try, but I'm guessing that if it works all that it will prove is that there's something wrong in the if (defined $ident) block later in the case of $page being blank.

      Update: the patch had no effect on the output. I think that, bad as it is, this section isn't the source of the problem.

        Hi, The diferent in the first if, changed by my previous patch is that $1 is set to '' (defined), and with my patch it is set to undef.