Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Pod-Simple CPAN distribution.

Report information
The Basics
Id: 15509
Status: resolved
Priority: 0/
Queue: Pod-Simple

People
Owner: Nobody in particular
Requestors: david [...] justatheory.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add Anchor Callbacks
I sent this patch to Sean a while ago. It adds a very simple callback for anchor tags, so that if a user needs to add more than the usual stuff to an anchor tag, she can. For the API browser that I wrote, this is essential for adding an onclick attribute to the anchor element. It looks something like this: $psh->perldoc_url_tag_extras_callback(sub { my ($url, $token) = @_; my $to = $token->attr('to') or return ''; my $search = PodBrowser::Pod::Search->instance or return ''; # If we have a local link, use podlink(). Otherwise, use leavelink(). return $search->name2path->{$to} ? qq{onclick="return podlink('$to');"} : qq{onclick="return leavelink(this)"}; }); Now, whether you want to generalize this into a callback architecture for all HTML tags I don't know. That'd certainly be fine with me. The upshot is that once this capabiliity is built into Pod::Simple::HTML (or there's some other way to do it--subclasses that override an "a" method?), I can release the pod browser code for general use. Here's what it looks like: http://www.bricolage.cc/docs/current/api/ Thanks! David
--- Pod/Simpmle/HTML.pm~ Mon Jun 7 21:27:06 2004 +++ Pod/Simple/HTML.pm Mon Jun 7 21:42:32 2004 @@ -52,6 +52,9 @@ 'perldoc_url_postfix', # what to put after "Foo%3a%3aBar" in the URL. Normally "". + # Want to add extra information to the anchor tag? + 'perldoc_url_tag_extras_callback', + 'batch_mode', # whether we're in batch mode 'batch_mode_current_level', # When in batch mode, how deep the current module is: 1 for "LWP", @@ -432,12 +435,15 @@ $linktype = $token->attr('type') || 'insane'; $linkto = $self->do_link($token); - if(defined $linkto and length $linkto) { esc($linkto); # (Yes, SGML-escaping applies on top of %-escaping! # But it's rarely noticeable in practice.) - print $fh qq{<a href="$linkto" class="podlink$linktype"\n>}; + my $extra = ''; + if (my $code = $self->perldoc_url_tag_extras_callback) { + $extra = ' ' . $code->($linkto, $token) . ' '; + } + print $fh qq{<a href="$linkto"$extra class="podlink$linktype"\n>}; } else { print $fh "<a>"; # Yes, an 'a' element with no attributes! }
From: allison [...] perl.org
Graham Barr sent me a related patch that adds additional behavior *after* the link has been printed. The two patches are similar in that they're both hooks for customizing anchors, but they're doing different things. It makes me think we need a more general way of allowing these customizations. (There are other cases of link fixups for particular sites or particular filetypes.) Could you send me a few examples of source pod and resulting html to get a better sense of how you're using it? (I've asked Graham for the same.)
no response for 3 years means no action.
I'll get with Allison and make this happen. We discussed it last month, we just need to bash a few bits together and get it in. Thanks, David
Allison tells me this is solved by the release of Pod::Simple::XHTML.