blib/lib/Template/Plugin/CommonMark.pm

filter: Statementstmt 85.7% 12 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 89.4% 17 / 19 CC 1 SCAR 0.6
CC
1
Cov
86%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 package Template::Plugin::CommonMark;
2  
3 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 our $VERSION = '1.000';
8 $VERSION = eval $VERSION;
9  
10 1 ▶use parent qw( Template::Plugin::Filter );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 0 ▶use CommonMark;
Subroutine BEGIN: called CC=1 SCAR=2.6
12  
13 sub init {
14 my $self = shift;
15 $self->{_DYNAMIC} = 1;
16  
17 my $name = $self->{ _ARGS }->[0] || 'cmark';
18 $self->install_filter($name);
19  
20 return $self;
21 }
22  
23 sub filter {
24 my ($self, $text, $args, $config) = @_;
25  
26 $config = { %{$self->{_CONFIG}}, %{$config || {}} };
27  
28 my $opt = CommonMark::OPT_DEFAULT;
29  
30 $config->{normalize} and $opt |= CommonMark::OPT_NORMALIZE;
31 $config->{validate_utf8} and $opt |= CommonMark::OPT_VALIDATE_UTF8;
32 $config->{smart} and $opt |= CommonMark::OPT_SMART;
33  
34 CommonMark->markdown_to_html($text, $opt)
35 }
36  
37 __PACKAGE__;
38 __END__
↑ Summary