line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simple::Wiki::Kwiki; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Pod::Simple::Wiki::Kwiki - A class for creating Pod to Kwiki 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
|
|
15
|
use Pod::Simple::Wiki; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
94
|
|
16
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
99
|
|
17
|
3
|
|
|
3
|
|
13
|
use vars qw(@ISA $VERSION); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2109
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@ISA = qw(Pod::Simple::Wiki); |
21
|
|
|
|
|
|
|
$VERSION = '0.20'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
############################################################################### |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# The tag to wiki mappings. |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
my $tags = { |
29
|
|
|
|
|
|
|
'' => '*', |
30
|
|
|
|
|
|
|
'' => '*', |
31
|
|
|
|
|
|
|
'' => '/', |
32
|
|
|
|
|
|
|
'' => '/', |
33
|
|
|
|
|
|
|
'' => '[=', |
34
|
|
|
|
|
|
|
'' => ']', |
35
|
|
|
|
|
|
|
'' => '', |
36
|
|
|
|
|
|
|
'' => "\n\n", |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
'' => "\n----\n= ", |
39
|
|
|
|
|
|
|
'' => " =\n\n", |
40
|
|
|
|
|
|
|
'' => "\n== ", |
41
|
|
|
|
|
|
|
'' => " ==\n\n", |
42
|
|
|
|
|
|
|
'' => "\n=== ", |
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
|
37
|
my $class = shift; |
58
|
22
|
|
|
|
|
73
|
my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); |
59
|
22
|
|
|
|
|
48
|
$self->{_tags} = $tags; |
60
|
|
|
|
|
|
|
|
61
|
22
|
|
|
|
|
37
|
bless $self, $class; |
62
|
22
|
|
|
|
|
67
|
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
|
|
50
|
my $self = shift; |
75
|
37
|
|
|
|
|
45
|
my $item_type = $_[0]; |
76
|
37
|
|
|
|
|
44
|
my $item_param = $_[1]; |
77
|
37
|
|
|
|
|
51
|
my $indent_level = $self->{_item_indent}; |
78
|
|
|
|
|
|
|
|
79
|
37
|
100
|
|
|
|
107
|
if ( $item_type eq 'bullet' ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
80
|
12
|
|
|
|
|
48
|
$self->_append( '*' x $indent_level . ' ' ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ( $item_type eq 'number' ) { |
83
|
12
|
|
|
|
|
41
|
$self->_append( '0' x $indent_level . ' ' ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif ( $item_type eq 'text' ) { |
86
|
13
|
|
|
|
|
49
|
$self->_append( ';' x $indent_level . ' ' ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
############################################################################### |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# _skip_headings() |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# Formatting in headings doesn't look great or is ignored in some formats. |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
sub _skip_headings { |
98
|
|
|
|
|
|
|
|
99
|
16
|
|
|
16
|
|
21
|
my $self = shift; |
100
|
|
|
|
|
|
|
|
101
|
16
|
50
|
33
|
|
|
188
|
if ( $self->{_in_head1} |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
102
|
|
|
|
|
|
|
or $self->{_in_head2} |
103
|
|
|
|
|
|
|
or $self->{_in_head3} |
104
|
|
|
|
|
|
|
or $self->{_in_head4} ) |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
|
|
0
|
return 1; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
############################################################################### |
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
# _handle_text() |
113
|
|
|
|
|
|
|
# |
114
|
|
|
|
|
|
|
# Perform any necessary transforms on the text. This is mainly used to escape |
115
|
|
|
|
|
|
|
# inadvertent CamelCase words. |
116
|
|
|
|
|
|
|
# |
117
|
|
|
|
|
|
|
sub _handle_text { |
118
|
|
|
|
|
|
|
|
119
|
60
|
|
|
60
|
|
443
|
my $self = shift; |
120
|
60
|
|
|
|
|
81
|
my $text = $_[0]; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Only escape CamelCase in Kwiki paragraphs |
123
|
60
|
100
|
|
|
|
135
|
if ( not $self->{_in_Para} ) { |
124
|
41
|
|
|
|
|
64
|
$self->{_wiki_text} .= $text; |
125
|
41
|
|
|
|
|
93
|
return; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Split the text into tokens but maintain the whitespace |
129
|
19
|
|
|
|
|
90
|
my @tokens = split /(\s+)/, $text; |
130
|
|
|
|
|
|
|
|
131
|
19
|
|
|
|
|
42
|
for ( @tokens ) { |
132
|
87
|
100
|
|
|
|
228
|
next unless /\S/; # Ignore the whitespace |
133
|
53
|
50
|
|
|
|
97
|
next if m[^(ht|f)tp://]; # Ignore URLs |
134
|
53
|
|
|
|
|
101
|
s/([A-Z][a-z]+[A-Z]\w+)/!$1/g; # Escape with ! |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Rejoin the tokens and whitespace. |
138
|
19
|
|
|
|
|
80
|
$self->{_wiki_text} .= join '', @tokens; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
############################################################################### |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
# Functions to deal with =over ... =back regions for |
145
|
|
|
|
|
|
|
# |
146
|
|
|
|
|
|
|
# Bulleted lists |
147
|
|
|
|
|
|
|
# Numbered lists |
148
|
|
|
|
|
|
|
# Text lists |
149
|
|
|
|
|
|
|
# Block lists |
150
|
|
|
|
|
|
|
# |
151
|
13
|
|
|
13
|
|
38
|
sub _end_item_text { $_[0]->_output( ' ; ' ) } |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
############################################################################### |
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
# _start_Para() |
157
|
|
|
|
|
|
|
# |
158
|
|
|
|
|
|
|
# Special handling for paragraphs that are part of an "over" block. |
159
|
|
|
|
|
|
|
# |
160
|
|
|
|
|
|
|
sub _start_Para { |
161
|
|
|
|
|
|
|
|
162
|
19
|
|
|
19
|
|
34
|
my $self = shift; |
163
|
19
|
|
|
|
|
29
|
my $indent_level = $self->{_item_indent}; |
164
|
|
|
|
|
|
|
|
165
|
19
|
100
|
|
|
|
69
|
if ( $self->{_in_over_block} ) { |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Do something here is necessary |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
############################################################################### |
173
|
|
|
|
|
|
|
# |
174
|
|
|
|
|
|
|
# _end_Para() |
175
|
|
|
|
|
|
|
# |
176
|
|
|
|
|
|
|
# Special handling for paragraphs that are part of an "over_text" block. |
177
|
|
|
|
|
|
|
# This is mainly required be Kwiki. |
178
|
|
|
|
|
|
|
# |
179
|
|
|
|
|
|
|
sub _end_Para { |
180
|
|
|
|
|
|
|
|
181
|
19
|
|
|
19
|
|
27
|
my $self = shift; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Only add a newline if the paragraph isn't part of a text. |
184
|
19
|
100
|
|
|
|
41
|
if ( $self->{_in_over_text} ) { |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# Workaround for the fact that Kwiki doesn't have a definition block. |
187
|
|
|
|
|
|
|
#$self->_output("\n"); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
else { |
190
|
7
|
|
|
|
|
21
|
$self->_output( "\n" ); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
19
|
|
|
|
|
48
|
$self->_output( "\n" ); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
__END__ |