Wiki/Usemod.pm

filter: Statementstmt 100% 35 / 35 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 98.0% 51 / 52 CC 5 SCAR 7.7
CC
5
Cov
98%
_indent_item
4.0
_start_Para
2.0
BEGIN
1.0
CRAP 2.2
« Wiki/Twiki.pm ↑ Summary
1 package Pod::Simple::Wiki::Usemod;
2  
3 ###############################################################################
4 #
5 # Pod::Simple::Wiki::Usemod - A class for creating Pod to Usemod filters.
6 #
7 #
8 # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org
9 #
10 # Documentation after __END__
11 #
12  
13 # perltidy with the following options: -mbl=2 -pt=0 -nola
14  
15 3 ▶use Pod::Simple::Wiki;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 3 @ISA = qw(Pod::Simple::Wiki);
21 3 $VERSION = '0.20';
22  
23  
24 ###############################################################################
25 #
26 # The tag to wiki mappings.
27 #
28 3 my $tags = {
29 '<b>' => '<b>',
30 '</b>' => '</b>',
31 '<i>' => '<i>',
32 '</i>' => '</i>',
33 '<tt>' => '<tt>',
34 '</tt>' => '</tt>',
35 '<pre>' => "\n<pre>\n",
36 '</pre>' => "\n</pre>\n\n",
37  
38 '<h1>' => "\n= ",
39 '</h1>' => " =\n\n",
40 '<h2>' => "\n== ",
41 '</h2>' => " ==\n\n",
42 '<h3>' => "\n=== ",
43 '</h3>' => " ===\n",
44 '<h4>' => "\n==== ",
45 '</h4>' => " ====\n\n",
46 };
47  
48  
49 ###############################################################################
50 #
51 # new()
52 #
53 # Simple constructor inheriting from Pod::Simple::Wiki.
54 #
55 22 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
56  
57 22 my $class = shift;
58 22 my $self = Pod::Simple::Wiki->new( 'wiki', @_ );
59 22 $self->{_tags} = $tags;
60  
61 22 bless $self, $class;
62 22 return $self;
63 }
64  
65  
66 ###############################################################################
67 #
68 # _indent_item()
69 #
70 # Indents an "over-item" to the correct level.
71 #
72 37 ▶sub _indent_item {
Subroutine _indent_item: called CC=4 SCAR=13.9
73  
74 37 my $self = shift;
75 37 my $item_type = $_[0];
76 37 my $item_param = $_[1];
77 37 my $indent_level = $self->{_item_indent};
78  
79 37 ▶ if ( $item_type eq 'bullet' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($item_type eq 'bullet') { } 12 25 37
elsif ($item_type eq 'number') { } 12 13 25
elsif ($item_type eq 'text') { } 13 0 13
80 12 $self->_append( '*' x $indent_level );
81 }
82 elsif ( $item_type eq 'number' ) {
83 12 $self->_append( '#' x $indent_level );
84 }
85 elsif ( $item_type eq 'text' ) {
86 13 $self->_append( ';' x $indent_level );
87 }
88 }
89  
90  
91 ###############################################################################
92 #
93 # _handle_text()
94 #
95 # Perform any necessary transforms on the text. This is mainly used to escape
96 # inadvertent CamelCase words.
97 #
98 60 ▶sub _handle_text {
Subroutine _handle_text: called CC=1 SCAR=0.0
99  
100 60 my $self = shift;
101 60 my $text = $_[0];
102  
103 # Split the text into tokens but maintain the whitespace
104 60 my @tokens = split /(\s+)/, $text;
105  
106 # Escape any tokens here.
107  
108 # Rejoin the tokens and whitespace.
109 60 $self->{_wiki_text} .= join '', @tokens;
110 }
111  
112  
113 ###############################################################################
114 #
115 # Functions to deal with =over ... =back regions for
116 #
117 # Bulleted lists
118 # Numbered lists
119 # Text lists
120 # Block lists
121 #
122 13 ▶sub _end_item_text { $_[0]->_output( ':' ) }
Subroutine _end_item_text: called CC=1 SCAR=0.0
123  
124  
125 ###############################################################################
126 #
127 # _start_Para()
128 #
129 # Special handling for paragraphs that are part of an "over" block.
130 #
131 19 ▶sub _start_Para {
Subroutine _start_Para: called CC=2 SCAR=6.9
132  
133 19 my $self = shift;
134 19 my $indent_level = $self->{_item_indent};
135  
136 19 ▶ if ( $self->{_in_over_block} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_in_over_block"}) 1 18 19
137 1 $self->_append( ":" x $indent_level );
138 }
139 }
140  
141  
142 3 1;
143  
144  
145 __END__
« Wiki/Twiki.pm ↑ Summary