| 1 | package Text::MetaMarkup::HTML::JuerdNL; | ||
| 2 | use strict; | ||
| 3 | use base qw( | ||
| 4 | Text::MetaMarkup::HTML | ||
| 5 | Text::MetaMarkup::AddOn::Raw | ||
| 6 | Text::MetaMarkup::AddOn::Perl | ||
| 7 | ); | ||
| 8 | |||
| 9 | sub link_ { | ||
| 10 | my ($self, $href, $text) = @_; | ||
| 11 | my $link = \$href->{href}; | ||
| 12 | my $exlinx = \%PLP::Script::exlinx; | ||
| 13 | return unless $href->{href} or $text; | ||
| 14 | $text ||= $$link; | ||
| 15 | $$link = $exlinx->{lc $$link} if exists $exlinx->{lc $$link}; | ||
| 16 | $$link = $$link =~ m[/] ? $$link : lc $$link; | ||
| 17 | return $self->SUPER::link($href, $text); | ||
| 18 | } | ||
| 19 | |||
| 20 | sub link_cpan { | ||
| 21 | my ($self, $href, $text) = @_; | ||
| 22 | $text ||= (split m[/], $href->{rest})[-1]; | ||
| 23 | $href->{rest} =~ s/::/-/g; | ||
| 24 | $href->{href} = "http://search.cpan.org/author/$href->{rest}/" . | ||
| 25 | (split /-/, $href->{rest})[-1] . ".pm"; | ||
| 26 | return $self->link($href, $text); | ||
| 27 | } | ||
| 28 | |||
| 29 | sub link { | ||
| 30 | my ($self, $href, $text) = @_; | ||
| 31 | $href = $self->escape($href->{href}); | ||
| 32 | $text = $href if not defined $text; | ||
| 33 | return sprintf | ||
| 34 | q[<a title="Off-site link: %s" href="/elsewhere.plp?href=%s" ] . | ||
| 35 | q[target=_blank>%s</a>], | ||
| 36 | $href, $href, | ||
| 37 | $self->parse_paragraph_text($text); | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | __END__ |