| 1 | package XML::XSS::Comment; | ||||||||||||||||||||||||||||
| 2 | BEGIN { | ||||||||||||||||||||||||||||
| 3 | 15 | ▶ | $XML::XSS::Comment::AUTHORITY = 'cpan:YANICK'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | { | ||||||||||||||||||||||||||||
| 6 | 15 | $XML::XSS::Comment::VERSION = '0.3.4'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | # ABSTRACT: XML::XSS comment stylesheet rule | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 15 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 15 | ▶ | use MooseX::SemiAffordanceAccessor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 15 | ▶ | use MooseX::Clone; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 15 | with 'XML::XSS::Role::Renderer', 'MooseX::Clone'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 15 | ▶ | no warnings qw/ uninitialized /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 15 | has [ qw/ showtag pre post rename replace process filter / ] => ( | |||||||||||||||||||||||||||
| 24 | traits => [ qw/ XML::XSS::Role::StyleAttribute Clone / ] ); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub apply { | ||||||||||||||||||||||||||||
| 27 | 4 | ▶ | my ( $self, $node, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
apply: called CC=14 SCAR=26.9
| |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | $args ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args ||= {}
MC/DC0%0/1
$args ||= {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | $DB::single = 1; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 4 | ▶ | return if $self->has_process and !$self->_render( 'process', $node, $args | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->has_process and not $self->_render("process", $node, $args)
MC/DC0%0/2
$self->has_process and not $self->_render("process", $node, $args)
$self->has_process
not $self->_render("process", $node, $args)
Truth table66%2/3
A and not(B)
A= $self->has_processB= not $self->_render("process", $node, $args)
| |||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | my $text = $node->data; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 4 | my $output; | |||||||||||||||||||||||||||
| 38 | 4 | $output .= $self->_render( 'pre', $node, $args ); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 4 | my $name; | |||||||||||||||||||||||||||
| 41 | 4 | ▶ | my $showtag = $self->_render( 'showtag', $node, $args ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_render("showtag", $node, $args) // ($self->has_pre ? 0 : 1)
MC/DC100%2/2
$self->_render("showtag", $node, $args) // ($self->has_pre ? 0 : 1)
$self->_render("showtag", $node, $args)
($self->has_pre ? 0 : 1)
Truth table100%3/3
A // B
A= $self->_render("showtag", $node, $args)B= ($self->has_pre ? 0 : 1)
| |||||||||||||||||||||||||||||
| 42 | // ( $self->has_pre ? 0 : 1 ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 4 | ▶ | if ( $showtag ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 3 | ▶ | $name = $self->has_rename && $self->_render( 'rename', $node, | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->has_rename && $self->_render('rename', $node, $args)
MC/DC50%1/2
$self->has_rename && $self->_render('rename', $node, $args)
$self->has_rename
$self->_render('rename', $node, $args)
Truth table66%2/3
A && B
A= $self->has_renameB= $self->_render('rename', $node, $args)
| |||||||||||||||||||||||||||||
| 46 | $args ); | ||||||||||||||||||||||||||||
| 47 | 3 | ▶ | $output .= $name ? "<$name>" : '<!--'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | ▶ | $text = $self->_render( 'replace', $node, $args ) if | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | $self->has_replace; | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 4 | ▶ | if ( $self->has_filter ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $text = $self->filter->() for $text; # quick alias to $_ | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 4 | $output .= $text; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | ▶ | $output .= $name ? "</$name>" : '-->' if $showtag; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 4 | $output .= $self->_render( 'post', $node, $args ); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 4 | return $output; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 15 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =pod | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head1 NAME | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | XML::XSS::Comment - XML::XSS comment stylesheet rule | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head1 VERSION | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | version 0.3.4 | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | use XML::XSS; | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | my $xss = XML::XSS->new; | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | my $cmt_style = $xss->comment; | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | $cmt_style->set_filter( sub { s/^/#/gm; $_ } ); | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | print $xss->render( '<doc><!-- foo -->yadah yadah</doc>' ); | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | A C<XML::XSS> rule that matches against the comment nodes of a | ||||||||||||||||||||||||||||
| 95 | document to be rendered. | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head1 RENDERING ATTRIBUTES | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | For a document, the displayed attributes follow the template: | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | pre | ||||||||||||||||||||||||||||
| 102 | [text] | ||||||||||||||||||||||||||||
| 103 | post | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head2 process, pre, showtag, rename, post | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | Same attribute behaviors as in C<XML::XSS::Element>. | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =head2 replace, filter | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | Same attribute behaviors as in C<XML::XSS::Text>. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Yanick Champoux <yanick@cpan.org> | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | This software is copyright (c) 2013 by Yanick Champoux. | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 122 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||||||||||