File Coverage

blib/lib/Pod/Simple/Wiki/Twiki.pm
Criterion Covered Total %
statement 30 30 100.0
branch 7 8 87.5
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 46 47 97.8


line stmt bran cond sub pod time code
1             package Pod::Simple::Wiki::Twiki;
2              
3             ###############################################################################
4             #
5             # Pod::Simple::Wiki::Twiki - A class for creating Pod to Twiki 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     3   12 use Pod::Simple::Wiki;
  3         3  
  3         80  
16 3     3   10 use strict;
  3         3  
  3         71  
17 3     3   10 use vars qw(@ISA $VERSION);
  3         3  
  3         1046  
18              
19              
20             @ISA = qw(Pod::Simple::Wiki);
21             $VERSION = '0.18';
22              
23              
24             ###############################################################################
25             #
26             # The tag to wiki mappings.
27             #
28             my $tags = {
29             '' => '*',
30             '' => '*',
31             '' => '_',
32             '' => '_',
33             '' => '=',
34             '' => '=',
35             '
'  => "\n\n", 
36             '' => "\n\n\n",
37              
38             '

' => '---+ ',

39             '' => "\n\n",
40             '

' => '---++ ',

41             '' => "\n\n",
42             '

' => '---+++ ',

43             '' => "\n\n",
44             '

' => '---++++ ',

45             '' => "\n\n",
46             };
47              
48              
49             ###############################################################################
50             #
51             # new()
52             #
53             # Simple constructor inheriting from Pod::Simple::Wiki.
54             #
55             sub new {
56              
57 22     22 1 25 my $class = shift;
58 22         51 my $self = Pod::Simple::Wiki->new( 'wiki', @_ );
59 22         39 $self->{_tags} = $tags;
60              
61 22         27 bless $self, $class;
62 22         43 return $self;
63             }
64              
65              
66             ###############################################################################
67             #
68             # _indent_item()
69             #
70             # Indents an "over-item" to the correct level.
71             #
72             sub _indent_item {
73              
74 37     37   31 my $self = shift;
75 37         30 my $item_type = $_[0];
76 37         23 my $item_param = $_[1];
77 37         36 my $indent_level = $self->{_item_indent};
78              
79 37 100       77 if ( $item_type eq 'bullet' ) {
    100          
    50          
80 12         34 $self->_append( ' ' x $indent_level . '* ' );
81             }
82             elsif ( $item_type eq 'number' ) {
83 12         29 $self->_append( ' ' x $indent_level . $item_param . '. ' );
84             }
85             elsif ( $item_type eq 'text' ) {
86 13         39 $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             sub _handle_text {
99              
100 60     60   361 my $self = shift;
101 60         42 my $text = $_[0];
102              
103             # Split the text into tokens but maintain the whitespace
104 60         246 my @tokens = split /(\s+)/, $text;
105              
106             # Escape any tokens here.
107              
108             # Rejoin the tokens and whitespace.
109 60         173 $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     13   26 sub _end_item_text { $_[0]->_output( ': ' ) }
123              
124              
125             ###############################################################################
126             #
127             # _start_Para()
128             #
129             # Special handling for paragraphs that are part of an "over" block.
130             #
131             sub _start_Para {
132              
133 19     19   26 my $self = shift;
134 19         19 my $indent_level = $self->{_item_indent};
135              
136 19 100       45 if ( $self->{_in_over_block} ) {
137              
138             # Do something here is necessary
139             }
140             }
141              
142              
143             1;
144              
145              
146             __END__