| 1 | package Text::Livedoor::Wiki::Plugin::Block::H3; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use base qw(Text::Livedoor::Wiki::Plugin::Block); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 301 | ▶ | sub check { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 301 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 301 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 301 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 301 | my $id = $args->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 301 | my $inline = $args->{inline}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 301 | my $on_next = $args->{on_next}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 301 | my $scratchpad = $Text::Livedoor::Wiki::scratchpad; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 301 | my $catalog_keeper = $Text::Livedoor::Wiki::opts->{catalog_keeper}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 301 | my $id_keeper = $Text::Livedoor::Wiki::opts->{id_keeper}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 301 | my $skip_catalog = $Text::Livedoor::Wiki::opts->{skip_catalog}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 301 | my $key = 'h3_is_active_' . $id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | #if ( $line =~ /^\*[^\*]./ && !$on_next && !$class->get_child($id) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 301 | ▶ | if ( $line =~ /^\*[^\*]+/ && !$on_next && !$class->get_child($id) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$line =~ /^\*[^\*]+/ and not $on_next and not $class->get_child($id)
$line =~ /^\*[^\*]+/ and not $on_next
MC/DC100%3/3
$line =~ /^\*[^\*]+/ and not $on_next and not $class->get_child($id)
$line =~ /^\*[^\*]+/
not $on_next
not $class->get_child($id)
Truth table100%4/4
A and not(B) and not(C)
A= $line =~ /^\*[^\*]+/B= not $on_nextC= not $class->get_child($id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 32 | $scratchpad->{$key} = 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 32 | $line =~ s/^\*//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 32 | my $title = $inline->parse($line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 32 | my $header = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 32 | my $header_meta = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 32 | $Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | ▶ | if( $skip_catalog ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | $header = sprintf( qq|<div class="title-1"><h3>%s</h3></div>\n| , $title ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 30 | $id_keeper->up(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 30 | $Text::Livedoor::Wiki::scratchpad->{core}{h3pos}{$id_keeper->id(1)} = $Text::Livedoor::Wiki::scratchpad->{core}{current_pos}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 30 | $catalog_keeper->append( {level=>1 , id => $id_keeper->id(1) , label => $title } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 30 | $header | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | = sprintf( qq|<div class="title-1"><h3 id="%s">%s</h3></div>\n| , $id_keeper->id(1) , $title ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 30 | $header_meta = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | id => $id_keeper->id(1), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | title => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 32 | return { id => $id , header => $header , header_meta => $header_meta }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ▶ | elsif( $on_next && $class->trigger_check($id,$line) && $line =~ /^\*/ && $scratchpad->{$key} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
$on_next and $class->trigger_check($id, $line) and $line =~ /^\*/ and $scratchpad->{$key}
$on_next and $class->trigger_check($id, $line) and $line =~ /^\*/
$on_next and $class->trigger_check($id, $line)
MC/DC75%3/4
$on_next and $class->trigger_check($id, $line) and $line =~ /^\*/ and $scratchpad->{$key}
$on_next
$class->trigger_check($id, $line)
$line =~ /^\*/
$scratchpad->{$key}
Truth table80%4/5
A and B and C and D
A= $on_nextB= $class->trigger_check($id, $line)C= $line =~ /^\*/D= $scratchpad->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 20 | $scratchpad->{$key} = 0 ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | return ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | elsif( $scratchpad->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 76 | return { line => $line }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 173 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 32 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 32 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 32 | my $block = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 32 | my $inline = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 32 | my $items = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 32 | my $meta = shift @{$items}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 32 | my $header = $meta->{header} ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 32 | my $id = $meta->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 32 | my $html = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 32 | $html .= $_->{line} . "\n" for @$items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 32 | $html =~ s/\n$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # block in block | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 32 | $html = $block->parse( $html , 1 ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 32 | return qq|<div id="$id" class="wiki-section-1">\n$header<div id="$id-body" class="wiki-section-body-1">\n$html</div>\n</div>\n|; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | Text::Livedoor::Wiki::Plugin::Block::H3 - H3 Block Plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | H3 is top level header. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | =head2 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | * Title | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | contents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | * Title2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Content | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =head1 FUNCTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | =head2 check | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | =head2 get | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | polocky | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||