develooper Front page | perl.perl5.porters | Postings from July 2011

Proposal: Make X<> useful inside =headN

Thread Next
From:
Rocco Caputo
Date:
July 19, 2011 06:32
Subject:
Proposal: Make X<> useful inside =headN
Message ID:
F1CBF804-6C64-42AC-BBF0-EE41322E3FD4@pobox.com
Specifically, make X<> define a substring of "=headN" to be used as
the section's anchor name:

	=head4 X<alarm> EVENT_NAME [, EPOCH_TIME [, PARAMETER_LIST] ]

X<>'s content is still used to "build indexes", but its content is
rendered when used in an anchorable paragraph.

You can see why I want this from the example above.  That section
heading's anchor is impractical without the X<>.

	<a name="alarm_event_name____epoch_time____parameter_list___">

Links to it must carefully replicate the entire heading and override
the default text.

	L<alarm|/alarm EVENT_NAME [, EPOCH_TIME [, PARAMETER_LIST] ]>

The slightest change to the section header ruins links near and far.

A naïve patch to Pod::Html, shown here for illustration, is rather
small:

*** Html-orig.pm	2010-11-11 21:02:47.000000000 -0500
--- /System/Library/Perl/5.10.0/Pod/Html.pm	2011-07-19 02:57:32.000000000 -0400
***************
*** 1025,1032 ****
        if ($line =~ /^=(head)([1-6])\s+(.*)/) {
          ($tag, $which_head, $otitle) = ($1,$2,$3);
  
          my $title = depod( $otitle );
!         my $name = anchorify( $title );
          $$sections{$name} = 1;
          $title = process_text( \$otitle );
  
--- 1025,1034 ----
        if ($line =~ /^=(head)([1-6])\s+(.*)/) {
          ($tag, $which_head, $otitle) = ($1,$2,$3);
  
+         my $oname = ($otitle =~ s/X<([^>]+)>/$1/ && $1);
+ 
          my $title = depod( $otitle );
!         my $name = anchorify( $oname // $title );
          $$sections{$name} = 1;
          $title = process_text( \$otitle );

When pressed, I don't really care how POD achieves useful section
anchors, as long as it does.

Thanks for your consideration.

-- 
Rocco Caputo <rcaputo@pobox.com>

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About