Wiki/Template.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 61 CC 6 SCAR 21.7
CC
6
Cov
0%
_indent_item
20.0
_handle_text
6.0
_start_Para
6.0
CRAP 8.8
1 package Pod::Simple::Wiki::Template;
2  
3 # Portme: This module is used as a boiler plate or example of how to create a
4 # new C<Pod::Simple::Wiki::> module.
5 #
6 # Read the Portme section of the documentation below for more information.
7 #
8 # Portme. Try to maintain the same code style as this module:
9 # perltidy with the following options: -mbl=2 -pt=0 -nola
10  
11  
12 ###############################################################################
13 #
14 # Pod::Simple::Wiki::Template - A class for creating Pod to Template filters.
15 #
16 #
17 # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org
18 #
19 # Documentation after __END__
20 #
21  
22 # perltidy with the following options: -mbl=2 -pt=0 -nola
23  
24 use Pod::Simple::Wiki;
25 use strict;
26 use vars qw(@ISA $VERSION);
27  
28  
29 @ISA = qw(Pod::Simple::Wiki);
30 $VERSION = '0.20';
31  
32 # Portme. Start with these tags.
33  
34 ###############################################################################
35 #
36 # The tag to wiki mappings.
37 #
38 my $tags = {
39 '<b>' => '*',
40 '</b>' => '*',
41 '<i>' => '/',
42 '</i>' => '/',
43 '<tt>' => '[=',
44 '</tt>' => ']',
45 '<pre>' => '',
46 '</pre>' => "\n\n",
47  
48 '<h1>' => "\n----\n= ",
49 '</h1>' => " =\n\n",
50 '<h2>' => "\n== ",
51 '</h2>' => " ==\n\n",
52 '<h3>' => "\n=== ",
53 '</h3>' => " ===\n\n",
54 '<h4>' => "==== ",
55 '</h4>' => "\n\n",
56 };
57  
58 # Portme. You can leave new() as it is.
59  
60 ###############################################################################
61 #
62 # new()
63 #
64 # Simple constructor inheriting from Pod::Simple::Wiki.
65 #
66 sub new {
67  
68 my $class = shift;
69 my $self = Pod::Simple::Wiki->new( 'wiki', @_ );
70 $self->{_tags} = $tags;
71  
72 bless $self, $class;
73 return $self;
74 }
75  
76 # Portme. How Pod "=over" blocks are converted to Template wiki lists.
77  
78 ###############################################################################
79 #
80 # _indent_item()
81 #
82 # Indents an "over-item" to the correct level.
83 #
84 sub _indent_item {
85  
86 my $self = shift;
87 my $item_type = $_[0];
88 my $item_param = $_[1];
89 my $indent_level = $self->{_item_indent};
90  
91 if ( $item_type eq 'bullet' ) {
92 $self->_append( '*' x $indent_level . ' ' );
93 }
94 elsif ( $item_type eq 'number' ) {
95 $self->_append( '0' x $indent_level . ' ' );
96 }
97 elsif ( $item_type eq 'text' ) {
98 $self->_append( ';' x $indent_level . ' ' );
99 }
100 }
101  
102 # Portme: Use this is text tokens need to be escaped, such as CamelCase words.
103  
104 ###############################################################################
105 #
106 # _handle_text()
107 #
108 # Perform any necessary transforms on the text. This is mainly used to escape
109 # inadvertent CamelCase words.
110 #
111 sub _handle_text {
112  
113 my $self = shift;
114 my $text = $_[0];
115  
116 # Only escape words in paragraphs
117 if ( not $self->{_in_Para} ) {
118 $self->{_wiki_text} .= $text;
119 return;
120 }
121  
122 # Split the text into tokens but maintain the whitespace
123 my @tokens = split /(\s+)/, $text;
124  
125 # Portme:
126 # Escape any tokens here, if necessary.
127  
128 # Rejoin the tokens and whitespace.
129 $self->{_wiki_text} .= join '', @tokens;
130 }
131  
132  
133 # Portme. How Pod "=over" blocks are converted to Template wiki lists.
134  
135 ###############################################################################
136 #
137 # Functions to deal with =over ... =back regions for
138 #
139 # Bulleted lists
140 # Numbered lists
141 # Text lists
142 # Block lists
143 #
144 sub _end_item_text { $_[0]->_output( ' ; ' ) }
145  
146  
147 # Portme: Probably won't have to change this.
148  
149 ###############################################################################
150 #
151 # _start_Para()
152 #
153 # Special handling for paragraphs that are part of an "over" block.
154 #
155 sub _start_Para {
156  
157 my $self = shift;
158 my $indent_level = $self->{_item_indent};
159  
160 if ( $self->{_in_over_block} ) {
161  
162 # Do something here is necessary
163 }
164 }
165  
166  
167 1;
168  
169  
170 __END__