Flute/Filter/Markdown.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
filter
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Template::Flute::Filter::Markdown;
2  
3 use strict;
4 use warnings;
5  
6 use base 'Template::Flute::Filter';
7  
8 use HTML::Scrubber;
9 use Text::Markdown;
10  
11 =head1 NAME
12  
13 Template::Flute::Filter::Markdown - markdown filter
14  
15 =head1 DESCRIPTION
16  
17 Turns text in Markdown format into HTML. The HTML
18 is subject to scrubbing with L<HTML::Scrubber>.
19  
20 =head1 PREREQUISITES
21  
22 L<HTML::Scrubber> module.
23 L<Text::Markdown> module.
24  
25 =head1 METHODS
26  
27 =head2 filter
28  
29 Markdown filter.
30  
31 =cut
32  
33 sub filter {
34 my ( $self, $value ) = @_;
35  
36 my $m = Text::Markdown->new;
37 my $s = HTML::Scrubber->new(
38 allow => [
39 qw/
40 a abbr b blockquote br caption cite colgroup dd del dl dt em
41 h1 h2 h3 h4 h5 h6 hr i img ins li ol p pre q small strong sub
42 sup table tbody td tfoot th thead tr u ul
43 /
44 ]
45 );
46 $s->rules(
47 a => {
48 href => 1,
49 '*' => 0,
50 },
51 img => {
52 src => 1,
53 alt => 1,
54 '*' => 0,
55 },
56 );
57 return $s->scrub( $m->markdown($value) );
58 }
59  
60 =head1 AUTHOR
61  
62 Peter Mottram (SysPete), <peter@sysnix.com>
63  
64 =head1 LICENSE AND COPYRIGHT
65  
66 Copyright 2011-2019 Stefan Hornburg (Racke) <racke@linuxia.de>.
67  
68 This program is free software; you can redistribute it and/or modify it
69 under the terms of either: the GNU General Public License as published
70 by the Free Software Foundation; or the Artistic License.
71  
72 See http://dev.perl.org/licenses/ for more information.
73  
74 =cut
75  
76 1;