File Coverage

blib/lib/Text/HTML/Turndown/Tasklistitems.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 22 23 95.6


line stmt bran cond sub pod time code
1             package Text::HTML::Turndown::Tasklistitems 0.12;
2 1     1   736 use 5.020;
  1         6  
3 1     1   7 use experimental 'signatures';
  1         3  
  1         8  
4 1     1   158 use stable 'postderef';
  1         2  
  1         24  
5 1     1   86 use List::MoreUtils 'all';
  1         3  
  1         8  
6              
7             our %RULES = (
8             taskListItems => {
9             filter => sub ($rule, $node, $options) {
10             return lc $node->getAttribute('type') eq 'checkbox'
11             && uc $node->parentNode->nodeName eq 'LI'
12             },
13             replacement => sub( $content, $node, $options, $context ) {
14             return (defined $node->getAttribute('checked') ? '[x]' : '[ ]') . ' '
15             }
16             },
17             );
18              
19 22     22 0 78 sub install ($class, $target) {
  22         49  
  22         38  
  22         46  
20 22         81 for my $key (keys %RULES) {
21 22         113 $target->addRule($key, $RULES{$key})
22             }
23             }
24              
25             1;