develooper Front page | perl.perl5.porters | Postings from April 2003

Re: [PATCH 5.8.0 UTIL] Fix installhtml for splitting and PM/POD conflicts

Thread Previous | Thread Next
Rafael Garcia-Suarez
April 2, 2003 04:36
Re: [PATCH 5.8.0 UTIL] Fix installhtml for splitting and PM/POD conflicts
Message ID:
Steve Hay wrote:
> I've also changed it to use anchorify() rather than htmlify().  This is 
> because the links written into the "index" page by pod2html() are 
> generated by anchorify(), so the names must match in order for the links 
> to work.  (Otherwise, for example, the perlipc.html "index" page will 
> have a link to "see_also.html", whereas the filename chosen by htmlize() 
> would be "see also.html" so the link is broken.)
> I've also inserted some other substitutions into the name returned by 
> htmlize() after the call to anchorify() because the name returned is to 
> be used as a filename, hence must not contain any invalid filename 
> characters.  For example, the perlipc manpage contains a "=head1" 
> section named "Sockets: Client/Server Communication" -- we must remove 
> the ":" and "/" characters before this can make a valid filename (on 
> Windows, at least).
> Are there any other characters that would be invalid in filenames on 
> other OS's?  Is there a generic "filename-cleaning-up" routine anywhere? 
>  (I couldn't see one in the File::Spec module.)

Playing on the safe side, I'd remove every non-alphanumeric char from
the anchor name (so there's only alphanum chars, and no more than one dot).
(Even a legal and innocent-looking filename, like '-rf', may cause problems.)

> This solution is not perfect since the links in the "index" page do not 
> have the additional substitutions applied to them.  Thus, in the above 
> example, the link would be 
> "perlipc/sockets:_client/server_communication.html" (only anchorified), 
> whereas the file would be 
> "perlipc/sockets__client_server_communication.html" (anchorified and 

So you have broken links in perlipc.html and in some of the
perlipc/*.html files.

> filenameified).  Perhaps the additional substitutions should be applied 
> within anchorify() itself?  However, that seems to be going beyond what 
> that function sounds like it is going to do?

Yes, I'm inclined to apply something like the patch below along your
patch. Thoughts ?

Index: lib/Pod/
--- lib/Pod/     (revision 1050)
+++ lib/Pod/     (working copy)
@@ -1965,12 +1965,12 @@
-# similar to htmlify, but turns spaces into underscores
+# similar to htmlify, but turns non-alphanumerics into underscores
 sub anchorify {
     my ($anchor) = @_;
     $anchor = htmlify($anchor);
-    $anchor =~ s/\s/_/g; # fixup spaces left by htmlify
+    $anchor =~ s/\W/_/g;
     return $anchor;
End of Patch.
Unresponsive is not *NIX

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About