| 1 | package Silki::Markdent::Handler::ExtractWikiLinks; | ||
| 2 | { | ||
| 3 | $Silki::Markdent::Handler::ExtractWikiLinks::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use List::AllUtils qw( any ); | ||
| 11 | use Silki::Types qw( HashRef ); | ||
| 12 | |||
| 13 | use Moose; | ||
| 14 | use MooseX::SemiAffordanceAccessor; | ||
| 15 | use MooseX::StrictConstructor; | ||
| 16 | |||
| 17 | with 'Markdent::Role::Handler', 'Silki::Markdent::Role::WikiLinkResolver'; | ||
| 18 | |||
| 19 | has links => ( | ||
| 20 | traits => ['Hash'], | ||
| 21 | is => 'ro', | ||
| 22 | isa => HashRef [HashRef], | ||
| 23 | init_arg => undef, | ||
| 24 | default => sub { {} }, | ||
| 25 | handles => { | ||
| 26 | _add_link => 'set', | ||
| 27 | }, | ||
| 28 | ); | ||
| 29 | |||
| 30 | # The WikiLinkResolver role does everything we need done for event handling. | ||
| 31 | sub handle_event { } | ||
| 32 | |||
| 33 | sub _replace_placeholder { | ||
| 34 | my $self = shift; | ||
| 35 | my $id = shift; | ||
| 36 | my $link_data = shift; | ||
| 37 | |||
| 38 | return unless $link_data && $link_data->{wiki}; | ||
| 39 | |||
| 40 | $self->_add_link( $id => $link_data ); | ||
| 41 | |||
| 42 | return; | ||
| 43 | } | ||
| 44 | |||
| 45 | __PACKAGE__->meta()->make_immutable(); | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | # ABSTRACT: Extracts all links from a Silki Markdown document | ||
| 50 | |||
| 51 | __END__ |