blib/lib/Kwiki/Footnote.pm

filter: Statementstmt 56.0% 28 / 50 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 1 totaltotal 57.3% 35 / 61 CC 2 SCAR 7.4
CC
2
Cov
56%
html
6.0
register
2.0
html
2.0
CRAP 2.1
↑ Summary
1 package Kwiki::Footnote;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.01';
5 1 ▶use Kwiki::Plugin '-Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Kwiki::Installer '-Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 const class_id => 'footnote';
9 1 const class_title => 'Footnote Wafl';
10 1 const css_file => 'footnote.css';
11  
12 1 field footnotes => [];
13  
14 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
15 0 my $registry = shift;
16 0 $registry->add(wafl => footnote => "Kwiki::Footnote::Footnote");
17 0 $registry->add(wafl => footnotelist => "Kwiki::Footnote::FootnoteList");
18 }
19  
20 package Kwiki::Footnote::Footnote;
21 1 ▶use base 'Spoon::Formatter::WaflPhrase';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 0 ▶sub html {
Subroutine html: not called CC=1 SCAR=6.9
24 0 my $text = $self->arguments;
25 0 my $footnotes = $self->hub->footnote->footnotes;
26 0 push @$footnotes, $text;
27 0 my $num = @$footnotes;
28 0 return <<EOF;
29 0 <sup id="fb$num"><a href="#fn$num" title="@{[$self->html_escape($text)]}">$num</a></sup>
30 EOF
31 }
32  
33 package Kwiki::Footnote::FootnoteList;
34 1 ▶use base 'Spoon::Formatter::WaflPhrase';
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 0 ▶sub html {
Subroutine html: not called CC=2 SCAR=17.9
37 0 my @footnotes = @{$self->hub->footnote->footnotes};
38 0 my $html = qq(<ul class="footnotelist">\n);
39 0 for my $idx (0..$#footnotes) {
40 0 my $text = $footnotes[$idx];
41 0 my $num = $idx + 1;
42 0 $html .= <<EOF
43 0 <li class="footnote"><cite id="fn$num"><a href="#fb$num">*$num</a></cite>: @{[$self->hub->formatter->text_to_html($text)]}</li>
44 EOF
45 ;
46 }
47 0 $html .= "</ul>\n";
48 0 return $html;
49 }
50  
51 package Kwiki::Footnote;
52 1 1;
53 1 __DATA__
↑ Summary