| blib/lib/Text/Livedoor/Wiki/Plugin/Block/H5.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 49 | 49 | 100.0 |
| branch | 8 | 8 | 100.0 |
| condition | 13 | 15 | 86.6 |
| subroutine | 5 | 5 | 100.0 |
| pod | 2 | 2 | 100.0 |
| total | 77 | 79 | 97.4 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Text::Livedoor::Wiki::Plugin::Block::H5; | ||||||
| 2 | |||||||
| 3 | 5 | 5 | 31 | use warnings; | |||
| 5 | 10 | ||||||
| 5 | 166 | ||||||
| 4 | 5 | 5 | 30 | use strict; | |||
| 5 | 10 | ||||||
| 5 | 175 | ||||||
| 5 | 5 | 5 | 24 | use base qw(Text::Livedoor::Wiki::Plugin::Block); | |||
| 5 | 10 | ||||||
| 5 | 1331 | ||||||
| 6 | |||||||
| 7 | sub check { | ||||||
| 8 | 185 | 185 | 1 | 342 | my $class = shift; | ||
| 9 | 185 | 295 | my $line = shift; | ||||
| 10 | 185 | 282 | my $args = shift; | ||||
| 11 | 185 | 338 | my $id = $args->{id}; | ||||
| 12 | 185 | 289 | my $inline = $args->{inline}; | ||||
| 13 | 185 | 312 | my $on_next = $args->{on_next}; | ||||
| 14 | 185 | 237 | my $scratchpad = $Text::Livedoor::Wiki::scratchpad; | ||||
| 15 | |||||||
| 16 | 185 | 295 | my $catalog_keeper = $Text::Livedoor::Wiki::opts->{catalog_keeper}; | ||||
| 17 | 185 | 361 | my $id_keeper = $Text::Livedoor::Wiki::opts->{id_keeper}; | ||||
| 18 | 185 | 266 | my $skip_catalog = $Text::Livedoor::Wiki::opts->{skip_catalog}; | ||||
| 19 | |||||||
| 20 | 185 | 398 | my $key = 'h5_is_active_' . $id; | ||||
| 21 | 185 | 100 | 100 | 1528 | if ( $line =~ /^\*\*\*/ && !$scratchpad->{$key} && !$class->get_child($id) ){ | ||
| 100 | 66 | ||||||
| 100 | 100 | ||||||
| 100 | |||||||
| 66 | |||||||
| 22 | 15 | 61 | $scratchpad->{$key} = 1 ; | ||||
| 23 | 15 | 72 | $line =~ s/^\*\*\*//; | ||||
| 24 | 15 | 73 | my $title = $inline->parse($line); | ||||
| 25 | 15 | 37 | my $header = ''; | ||||
| 26 | |||||||
| 27 | #XXX | ||||||
| 28 | 15 | 41 | $Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1'; | ||||
| 29 | |||||||
| 30 | 15 | 100 | 50 | if( $skip_catalog ) { | |||
| 31 | 1 | 6 | $header = sprintf( qq|%s |
||||
| 32 | } | ||||||
| 33 | else { | ||||||
| 34 | 14 | 68 | $id_keeper->up(3); | ||||
| 35 | 14 | 59 | $catalog_keeper->append( {level=>3 , id => $id_keeper->id(3) , label => $title } ); | ||||
| 36 | 14 | 57 | $header = sprintf( qq|%s |
||||
| 37 | } | ||||||
| 38 | 15 | 133 | return { header => $header , id => $id }; | ||||
| 39 | } | ||||||
| 40 | elsif( $on_next && $class->trigger_check($id,$line) && $line =~ /^\*/ && $scratchpad->{$key} ) { | ||||||
| 41 | 9 | 22 | $scratchpad->{$key} = 0 ; | ||||
| 42 | 9 | 43 | return ; | ||||
| 43 | } | ||||||
| 44 | elsif( $scratchpad->{$key} ) { | ||||||
| 45 | 20 | 121 | return { line => $line }; | ||||
| 46 | } | ||||||
| 47 | 141 | 704 | return; | ||||
| 48 | |||||||
| 49 | } | ||||||
| 50 | |||||||
| 51 | sub get { | ||||||
| 52 | 15 | 15 | 1 | 27 | my $class = shift; | ||
| 53 | 15 | 30 | my $block = shift; | ||||
| 54 | 15 | 26 | my $inline = shift; | ||||
| 55 | 15 | 21 | my $items = shift; | ||||
| 56 | 15 | 19 | my $meta = shift @{$items}; | ||||
| 15 | 36 | ||||||
| 57 | 15 | 59 | my $header = $meta->{header} ; | ||||
| 58 | 15 | 30 | my $id = $meta->{id} ; | ||||
| 59 | 15 | 35 | my $html = ''; | ||||
| 60 | 15 | 66 | $html .= $_->{line} . "\n" for @$items; | ||||
| 61 | 15 | 48 | $html =~ s/\n$//; | ||||
| 62 | 15 | 70 | $html = $block->parse( $html , 1 ) ; | ||||
| 63 | 15 | 158 | return qq| \n$header \n|; \n$html \n |
||||
| 64 | } | ||||||
| 65 | |||||||
| 66 | 1; | ||||||
| 67 | |||||||
| 68 | =head1 NAME | ||||||
| 69 | |||||||
| 70 | Text::Livedoor::Wiki::Plugin::Block::H5 - H5 Block Plugin | ||||||
| 71 | |||||||
| 72 | =head1 DESCRIPTION | ||||||
| 73 | |||||||
| 74 | H5 is third level header | ||||||
| 75 | |||||||
| 76 | =head1 SYNOPSIS | ||||||
| 77 | |||||||
| 78 | ** title3 | ||||||
| 79 | |||||||
| 80 | content | ||||||
| 81 | |||||||
| 82 | ** title3 | ||||||
| 83 | |||||||
| 84 | =head1 FUNCTION | ||||||
| 85 | |||||||
| 86 | =head2 check | ||||||
| 87 | |||||||
| 88 | =head2 get | ||||||
| 89 | |||||||
| 90 | =head1 AUTHOR | ||||||
| 91 | |||||||
| 92 | polocky | ||||||
| 93 | |||||||
| 94 | =cut |