| Text-AutoLink documentation | Contained in the Text-AutoLink distribution. |
Text::AutoLink::Plugin - Base Class For Text::AutoLink Plugin
package MyPlugin;
use strict;
use base qw(Text::AutoLink::Plugin);
sub process { ... }
Base class for Text::AutoLink Plugin.
Creates a new plugin instance.
You can specify the "target" attribute of the resulting link here
This method must be overridden in the subclass. It receives a scalar ref, which is the text that you should be modifying.
Returns false if not replacement was performed. Returns true otherwise.
The link text.
The target text. Overrides the value provided to new()
The linked text. The value of 'href' is used if not specified.
| Text-AutoLink documentation | Contained in the Text-AutoLink distribution. |
# $Id: /mirror/perl/Text-AutoLink/trunk/lib/Text/AutoLink/Plugin.pm 4207 2007-10-27T13:33:47.814555Z daisuke $ # # Copyright (c) 2006 Daisuke Maki <dmaki@cpan.org> # All rights reserved. package Text::AutoLink::Plugin; use strict; use warnings; sub new { my $class = shift; my %args = @_; my $self = bless { target => $args{target} || '', }, $class; return $self; } sub process { die } sub linkfy { my $self = shift; my %args = @_; my $target = exists $args{target} ? ($args{target} || '') : $self->{target}; if ($target) { $target = qq| target="$target"|; } return sprintf('<a href="%s"%s>%s</a>', $args{href}, $target, $args{text} || $args{href}); } 1; __END__