File Coverage

blib/lib/Markdent/Handler/HTMLFilter.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             package Markdent::Handler::HTMLFilter;
2              
3 1     1   12777 use strict;
  1         12  
  1         28  
4 1     1   5 use warnings;
  1         1  
  1         50  
5 1     1   459 use namespace::autoclean;
  1         16682  
  1         4  
6              
7             our $VERSION = '0.39';
8              
9 1     1   540 use Markdent::CapturedEvents;
  1         5  
  1         38  
10              
11 1     1   9 use Moose;
  1         2  
  1         7  
12 1     1   5799 use MooseX::StrictConstructor;
  1         2  
  1         7  
13              
14             with 'Markdent::Role::FilterHandler';
15              
16             sub filter_event {
17 14     14 0 18 my $self = shift;
18 14         19 my $event = shift;
19              
20             return
21 14 100       20 if grep { $event->isa( 'Markdent::Event::' . $_ ) }
  84         312  
22             qw(
23             HTMLBlock
24             HTMLComment
25             HTMLCommentBlock
26             HTMLTag
27             StartHTMLTag
28             EndHTMLTag
29             );
30              
31 10         246 $self->handler->handle_event($event);
32              
33 10         351 return;
34             }
35              
36             __PACKAGE__->meta->make_immutable;
37              
38             1;
39              
40             # ABSTRACT: Filters out HTML events from the event stream
41              
42             __END__
43              
44             =pod
45              
46             =encoding UTF-8
47              
48             =head1 NAME
49              
50             Markdent::Handler::HTMLFilter - Filters out HTML events from the event stream
51              
52             =head1 VERSION
53              
54             version 0.39
55              
56             =head1 SYNOPSIS
57              
58             my $html = Markdent::Handler::HTMLStream->new( ... );
59              
60             my $filter = Markdent::Handler::HTMLFilter->new( handler => $html );
61              
62             my $parser = Markdent::Parser->new( handler => $filter ):
63              
64             $parser->parse( markdown => ... );
65              
66             =head1 DESCRIPTION
67              
68             This class implements an event filter which drops all HTML events I<except>
69             for HTML entities.
70              
71             =head1 METHODS
72              
73             This class provides the following methods:
74              
75             =head2 Markdent::Handler::HTMLFilter->new
76              
77             This method creates a new handler.
78              
79             =head1 ROLES
80              
81             This class does the L<Markdent::Role::Handler> role.
82              
83             =head1 BUGS
84              
85             See L<Markdent> for bug reporting details.
86              
87             Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>.
88              
89             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
90              
91             =head1 SOURCE
92              
93             The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>.
94              
95             =head1 AUTHOR
96              
97             Dave Rolsky <autarch@urth.org>
98              
99             =head1 COPYRIGHT AND LICENSE
100              
101             This software is copyright (c) 2021 by Dave Rolsky.
102              
103             This is free software; you can redistribute it and/or modify it under
104             the same terms as the Perl 5 programming language system itself.
105              
106             The full text of the license can be found in the
107             F<LICENSE> file included with this distribution.
108              
109             =cut