File Coverage

blib/lib/Rubric/Entry/Formatter/HTMLEscape.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 22 26 84.6


line stmt bran cond sub pod time code
1 1     1   6 use strict;
  1         1  
  1         27  
2 1     1   4 use warnings;
  1         3  
  1         33  
3             # ABSTRACT: format into HTML by escaping entities
4              
5             #pod =head1 DESCRIPTION
6             #pod
7             #pod This formatter only handles formatting to HTML, and outputs the original
8             #pod content with HTML-unsafe characters escaped and paragraphs broken.
9             #pod
10             #pod This is equivalent to filtering with Template::Filters' C<html> and
11             #pod C<html_para> filters.
12             #pod
13             #pod =cut
14              
15             use Template::Filters;
16 1     1   4  
  1         2  
  1         162  
17             #pod =head1 METHODS
18             #pod
19             #pod =cut
20              
21             my ($filter, $html, $para);
22             {
23             my $filters = Template::Filters->new;
24             $html = $filters->fetch('html');
25             $para = $filters->fetch('html_para');
26              
27             $filter = sub {
28             $para->( $html->($_[0]) );
29             }
30             }
31              
32             my ($class, $arg) = @_;
33             return '' unless $arg->{text};
34 1     1 0 2 return $filter->($arg->{text});
35 1 50       2 }
36 1         8  
37             my ($class, $arg) = @_;
38             return '' unless $arg->{text};
39             return $html->($arg->{text});
40 1     1 0 2 }
41 1 50       3  
42 1         2 1;
43              
44              
45             =pod
46              
47             =encoding UTF-8
48              
49             =head1 NAME
50              
51             Rubric::Entry::Formatter::HTMLEscape - format into HTML by escaping entities
52              
53             =head1 VERSION
54              
55             version 0.157
56              
57             =head1 DESCRIPTION
58              
59             This formatter only handles formatting to HTML, and outputs the original
60             content with HTML-unsafe characters escaped and paragraphs broken.
61              
62             This is equivalent to filtering with Template::Filters' C<html> and
63             C<html_para> filters.
64              
65             =head1 PERL VERSION
66              
67             This code is effectively abandonware. Although releases will sometimes be made
68             to update contact info or to fix packaging flaws, bug reports will mostly be
69             ignored. Feature requests are even more likely to be ignored. (If someone
70             takes up maintenance of this code, they will presumably remove this notice.)
71             This means that whatever version of perl is currently required is unlikely to
72             change -- but also that it might change at any new maintainer's whim.
73              
74             =head1 METHODS
75              
76             =head1 AUTHOR
77              
78             Ricardo SIGNES <rjbs@semiotic.systems>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2004 by Ricardo SIGNES.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut