File Coverage

blib/lib/Pod/Simple/Wiki/Wikka.pm
Criterion Covered Total %
statement 33 33 100.0
branch 9 10 90.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 51 52 98.0


line stmt bran cond sub pod time code
1             package Pod::Simple::Wiki::Wikka;
2            
3 4     4   38869 use Pod::Simple::Wiki;
  4         173571  
  4         122  
4 4     4   48 use strict;
  4         10  
  4         140  
5 4     4   20 use vars qw(@ISA $VERSION);
  4         11  
  4         2078  
6            
7            
8             @ISA = qw(Pod::Simple::Wiki);
9             $VERSION = '0.09';
10            
11             ###############################################################################
12             #
13             # The tag to wiki mappings.
14             #
15             my $tags = {
16             '' => '**',
17             '' => '**',
18             '' => '//',
19             '' => '//',
20             '' => '##',
21             '' => '##',
22             '
'  => '',
 
23             '' => "\n\n",
24            
25             '

' => "\n====== ",

26             '' => " ======\n\n",
27             '

' => "\n===== ",

28             '' => " =====\n\n",
29             '

' => "\n==== ",

30             '' => " ====\n\n",
31             '

' => "\n=== ",

32             '' => " ===\n\n",
33             };
34            
35             ###############################################################################
36             #
37             # new()
38             #
39             # Simple constructor inheriting from Pod::Simple::Wiki.
40             #
41             sub new {
42            
43 23     23 1 17424 my $class = shift;
44 23         107 my $self = Pod::Simple::Wiki->new('wiki', @_);
45 23         1705 $self->{_tags} = $tags;
46            
47 23         61 bless $self, $class;
48 23         79 return $self;
49             }
50            
51             ###############################################################################
52             #
53             # _indent_item()
54             #
55             # Indents an "over-item" to the correct level.
56             #
57             sub _indent_item {
58            
59 37     37   23698 my $self = shift;
60 37         57 my $item_type = $_[0];
61 37         45 my $item_param = $_[1];
62 37         60 my $indent_level = $self->{_item_indent};
63            
64 37 100       125 if ($item_type eq 'bullet') {
    100          
    50          
65 12         57 $self->_append('~' x $indent_level . '- ');
66             }
67             elsif ($item_type eq 'number') {
68 12         50 $self->_append('~' x $indent_level . '1) ');
69             }
70             elsif ($item_type eq 'text') {
71 13         51 $self->_append('~' x $indent_level . '');
72             }
73             }
74            
75             ###############################################################################
76             #
77             # _handle_text()
78             #
79             # Perform any necessary transforms on the text. This is mainly used to escape
80             # inadvertent CamelCase words.
81             #
82             sub _handle_text {
83            
84 60     60   6153 my $self = shift;
85 60         87 my $text = $_[0];
86            
87             # Only escape words in paragraphs
88 60 100       257 if (not $self->{_in_Para}) {
89 41         75 $self->{_wiki_text} .= $text;
90 41         107 return;
91             }
92            
93             # Split the text into tokens but maintain the whitespace
94 19         119 my @tokens = split /(\s+)/, $text;
95            
96             # Portme:
97             # Escape any tokens here, if necessary.
98            
99             # Rejoin the tokens and whitespace.
100 19         97 $self->{_wiki_text} .= join '', @tokens;
101             }
102            
103            
104             ###############################################################################
105             #
106             # Functions to deal with =over ... =back regions for
107             #
108             # Bulleted lists
109             # Numbered lists
110             # Text lists
111             # Block lists
112             #
113 13     13   154 sub _end_item_text {$_[0]->_output("\n")}
114            
115            
116             ###############################################################################
117             #
118             # _start_Para()
119             #
120             # Special handling for paragraphs that are part of an "over" block.
121             #
122             sub _start_Para {
123            
124 19     19   9730 my $self = shift;
125 19         46 my $indent_level = $self->{_item_indent};
126            
127 19 100       87 if ($self->{_in_over_block}) {
128             # Do something here is necessary
129             }
130             }
131            
132            
133             1;
134            
135            
136             __END__