/usr/share/perl5/Wiki/Toolkit/Formatter/WikiLinkFormatterParent.pm is in libwiki-toolkit-perl 0.85-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | package Wiki::Toolkit::Formatter::WikiLinkFormatterParent;
use strict;
use vars qw( $VERSION @_links_found );
$VERSION = '0.01';
use Text::WikiFormat as => 'wikiformat';
=head1 NAME
Wiki::Toolkit::Formatter::WikiLinkFormatterParent - The parent of Wiki::Toolkit formatters that work with Wiki Links.
=head1 DESCRIPTION
A provider of common formatter methods for L<Wiki::Toolkit> formatters that
deal with Wiki Links.
=cut
sub new {
my ($class, @args) = @_;
my $self = {};
bless $self, $class;
$self->_init(@args) or return undef;
return $self;
}
=head1 METHODS
=head2 C<rename_links>
$formatter->rename_links( $from, $to, $content );
Renames all the links to a certain page in the supplied content.
(Obviously this is dependent on object properties such as
C<extended_links> and C<implicit_links>.)
=cut
sub rename_links {
my ($self, $from, $to, $content) = @_;
# If we support extended (square bracket) links, update those
if($self->{_extended_links}) {
$content =~ s/\[$from\]/\[$to\]/g;
$content =~ s/\[$from(\s*|.*?)\]/\[$to$1\]/g;
}
# If we support implicit (camelcase) links, update those
if($self->{_implicit_links}) {
$content =~ s/\b$from\b/$to/g;
$content =~ s/^$from\b/$to/gm;
$content =~ s/\b$from$/$to/gm;
}
return $content;
}
=head2 C<find_internal_links>
my @links_to = $formatter->find_internal_links( $content );
Returns a list of all nodes that the supplied content links to.
(Obviously this is dependent on object properties such as
C<extended_links> and C<implict_links>.)
=cut
sub find_internal_links {
my ($self, $raw) = @_;
@_links_found = ();
my $foo = wikiformat($raw,
{ link => sub {
my ($link, $opts) = @_;
$opts ||= {};
my $title;
($link, $title) = split(/\|/, $link, 2)
if $opts->{extended};
push @Wiki::Toolkit::Formatter::WikiLinkFormatterParent::_links_found,
$link;
return ""; # don't care about output
}
},
{
extended => $self->{_extended_links},
prefix => $self->{_node_prefix},
implicit_links => $self->{_implicit_links}
}
);
my @links = @_links_found;
@_links_found = ();
return @links;
}
=head1 SEE ALSO
L<Wiki::Toolkit::Formatter::Default>
=head1 AUTHOR
Kake Pugh (kake@earth.li).
=head1 COPYRIGHT
Copyright (C) 2002-2003 Kake Pugh. All Rights Reserved.
Copyright (C) 2006-2009 the Wiki::Toolkit team. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1;
|