blib/lib/Text/Livedoor/Wiki/Plugin/Block/H3.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 52 | 52 | 100.0 |
branch | 8 | 8 | 100.0 |
condition | 14 | 15 | 93.3 |
subroutine | 5 | 5 | 100.0 |
pod | 2 | 2 | 100.0 |
total | 81 | 82 | 98.7 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Text::Livedoor::Wiki::Plugin::Block::H3; | ||||||
2 | |||||||
3 | 5 | 5 | 31 | use warnings; | |||
5 | 11 | ||||||
5 | 149 | ||||||
4 | 5 | 5 | 25 | use strict; | |||
5 | 12 | ||||||
5 | 149 | ||||||
5 | 5 | 5 | 26 | use base qw(Text::Livedoor::Wiki::Plugin::Block); | |||
5 | 9 | ||||||
5 | 1553 | ||||||
6 | |||||||
7 | sub check { | ||||||
8 | 301 | 301 | 1 | 452 | my $class = shift; | ||
9 | 301 | 397 | my $line = shift; | ||||
10 | 301 | 413 | my $args = shift; | ||||
11 | 301 | 486 | my $id = $args->{id}; | ||||
12 | 301 | 498 | my $inline = $args->{inline}; | ||||
13 | 301 | 512 | my $on_next = $args->{on_next}; | ||||
14 | 301 | 428 | my $scratchpad = $Text::Livedoor::Wiki::scratchpad; | ||||
15 | |||||||
16 | |||||||
17 | 301 | 3490 | my $catalog_keeper = $Text::Livedoor::Wiki::opts->{catalog_keeper}; | ||||
18 | 301 | 438 | my $id_keeper = $Text::Livedoor::Wiki::opts->{id_keeper}; | ||||
19 | 301 | 580 | my $skip_catalog = $Text::Livedoor::Wiki::opts->{skip_catalog}; | ||||
20 | |||||||
21 | 301 | 744 | my $key = 'h3_is_active_' . $id; | ||||
22 | #if ( $line =~ /^\*[^\*]./ && !$on_next && !$class->get_child($id) ){ | ||||||
23 | 301 | 100 | 100 | 2696 | if ( $line =~ /^\*[^\*]+/ && !$on_next && !$class->get_child($id) ){ | ||
100 | 100 | ||||||
100 | 100 | ||||||
100 | |||||||
66 | |||||||
24 | 32 | 99 | $scratchpad->{$key} = 1 ; | ||||
25 | 32 | 147 | $line =~ s/^\*//; | ||||
26 | 32 | 142 | my $title = $inline->parse($line); | ||||
27 | 32 | 67 | my $header = ''; | ||||
28 | 32 | 68 | my $header_meta = {}; | ||||
29 | |||||||
30 | #XXX | ||||||
31 | 32 | 95 | $Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1'; | ||||
32 | |||||||
33 | 32 | 100 | 112 | if( $skip_catalog ) { | |||
34 | 2 | 9 | $header = sprintf( qq|%s |
||||
35 | } | ||||||
36 | else { | ||||||
37 | 30 | 173 | $id_keeper->up(1); | ||||
38 | 30 | 212 | $Text::Livedoor::Wiki::scratchpad->{core}{h3pos}{$id_keeper->id(1)} = $Text::Livedoor::Wiki::scratchpad->{core}{current_pos}; | ||||
39 | 30 | 133 | $catalog_keeper->append( {level=>1 , id => $id_keeper->id(1) , label => $title } ); | ||||
40 | 30 | 110 | $header | ||||
41 | = sprintf( qq|%s |
||||||
42 | 30 | 142 | $header_meta = { | ||||
43 | id => $id_keeper->id(1), | ||||||
44 | title => $title, | ||||||
45 | }; | ||||||
46 | } | ||||||
47 | 32 | 293 | return { id => $id , header => $header , header_meta => $header_meta }; | ||||
48 | } | ||||||
49 | elsif( $on_next && $class->trigger_check($id,$line) && $line =~ /^\*/ && $scratchpad->{$key} ) { | ||||||
50 | 20 | 43 | $scratchpad->{$key} = 0 ; | ||||
51 | 20 | 95 | return ; | ||||
52 | } | ||||||
53 | elsif( $scratchpad->{$key} ) { | ||||||
54 | 76 | 495 | return { line => $line }; | ||||
55 | } | ||||||
56 | 173 | 915 | return; | ||||
57 | |||||||
58 | } | ||||||
59 | |||||||
60 | sub get { | ||||||
61 | 32 | 32 | 1 | 67 | my $class = shift; | ||
62 | 32 | 57 | my $block = shift; | ||||
63 | 32 | 48 | my $inline = shift; | ||||
64 | 32 | 54 | my $items = shift; | ||||
65 | 32 | 49 | my $meta = shift @{$items}; | ||||
32 | 70 | ||||||
66 | 32 | 66 | my $header = $meta->{header} ; | ||||
67 | 32 | 64 | my $id = $meta->{id}; | ||||
68 | 32 | 51 | my $html = ''; | ||||
69 | 32 | 138 | $html .= $_->{line} . "\n" for @$items; | ||||
70 | 32 | 114 | $html =~ s/\n$//; | ||||
71 | # block in block | ||||||
72 | 32 | 144 | $html = $block->parse( $html , 1 ) ; | ||||
73 | 32 | 279 | return qq| \n$header \n|; \n$html \n |
||||
74 | } | ||||||
75 | |||||||
76 | 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 |