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