| 1 | package Template::Plugin::MultiMarkdown; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 6 | our $VERSION = "0.11"; | |||||||||||||
| 7 | |||||||||||||||
| 8 | 6 | ▶ | use vars qw($text_mmd_class); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 6 | ▶ | use parent qw (Template::Plugin::Filter); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 6 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | BEGIN { | ||||||||||||||
| 13 | 6 | ▶ | $text_mmd_class = 'Text::MultiMarkdown::XS'; | ||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.6
| |||||||||||||||
| 14 | 6 | eval 'require Text::MultiMarkdown::XS'; | |||||||||||||
| 15 | 6 | ▶ | if ($@) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | 6 | $text_mmd_class = 'Text::MultiMarkdown'; | |||||||||||||
| 17 | 6 | eval 'require Text::MultiMarkdown'; | |||||||||||||
| 18 | 6 | ▶ | if ($@) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 19 | 0 | croak "cannot load either Text::MultiMarkdown::XS or Text::MultiMarkdown"; | |||||||||||||
| 20 | } | ||||||||||||||
| 21 | } | ||||||||||||||
| 22 | } | ||||||||||||||
| 23 | |||||||||||||||
| 24 | sub init { | ||||||||||||||
| 25 | 5 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||
| 26 | 5 | $self->{_DYNAMIC} = 1; | |||||||||||||
| 27 | 5 | ▶ | $self->install_filter($self->{_ARGS}->[0] || 'multimarkdown'); | ||||||||||||
|
Condition50%1/2
$self->{'_ARGS'}[0] || 'multimarkdown'
MC/DC0%0/1
$self->{'_ARGS'}[0] || 'multimarkdown'
$self->{'_ARGS'}[0]
Truth table50%1/2
A
A= $self->{'_ARGS'}[0]
| |||||||||||||||
| 28 | 5 | return $self; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | |||||||||||||||
| 31 | sub filter { | ||||||||||||||
| 32 | 5 | ▶ | my ($self, $text, $args, $config) = @_; | ||||||||||||
|
Subroutine
filter: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||
| 33 | |||||||||||||||
| 34 | 5 | ▶ | my $options = { %{$self->{_CONFIG}}, %{$config || {}} }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 35 | 5 | ▶ | my $req_class = delete $options->{implementation} || ''; | ||||||||||||
|
Condition100%2/2
delete $options->{'implementation'} || ''
MC/DC100%1/1
delete $options->{'implementation'} || ''
delete $options->{'implementation'}
Truth table100%2/2
A
A= delete $options->{'implementation'}
| |||||||||||||||
| 36 | |||||||||||||||
| 37 | 5 | ▶ | if ($req_class eq 'PP') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 38 | 4 | require Text::MultiMarkdown; | |||||||||||||
| 39 | 4 | return Text::MultiMarkdown->new(%$options)->markdown($text); | |||||||||||||
| 40 | } elsif ($req_class eq 'XS') { | ||||||||||||||
| 41 | 0 | require Text::MultiMarkdown::XS; | |||||||||||||
| 42 | 0 | return Text::MultiMarkdown::XS->new($options)->markdown($text); | |||||||||||||
| 43 | } else { | ||||||||||||||
| 44 | 1 | return $text_mmd_class->new(%$options)->markdown($text); | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 6 | 1; | |||||||||||||
| 49 | |||||||||||||||
| 50 | __END__ | ||||||||||||||