line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simple::Wiki::Confluence; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Pod::Simple::Wiki::Confluence - A class for creating Pod to Confluence 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
|
4
|
|
|
4
|
|
20
|
use Pod::Simple::Wiki; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
122
|
|
16
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
99
|
|
17
|
4
|
|
|
4
|
|
18
|
use vars qw(@ISA $VERSION); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2874
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@ISA = qw(Pod::Simple::Wiki); |
21
|
|
|
|
|
|
|
$VERSION = '0.20'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
############################################################################### |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
# The tag to wiki mappings. |
26
|
|
|
|
|
|
|
# |
27
|
|
|
|
|
|
|
my $tags = { |
28
|
|
|
|
|
|
|
'' => '*', |
29
|
|
|
|
|
|
|
'' => '*', |
30
|
|
|
|
|
|
|
'' => '_', |
31
|
|
|
|
|
|
|
'' => '_', |
32
|
|
|
|
|
|
|
'' => '{{', |
33
|
|
|
|
|
|
|
'' => '}}', |
34
|
|
|
|
|
|
|
'' => "{noformat}\n", |
35
|
|
|
|
|
|
|
'' => "\n{noformat}\n", |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
'' => 'h1. ', |
38
|
|
|
|
|
|
|
'' => "\n\n", |
39
|
|
|
|
|
|
|
'' => 'h2. ', |
40
|
|
|
|
|
|
|
'' => "\n\n", |
41
|
|
|
|
|
|
|
'' => 'h3. ', |
42
|
|
|
|
|
|
|
'' => "\n\n", |
43
|
|
|
|
|
|
|
'' => 'h4. ', |
44
|
|
|
|
|
|
|
'' => "\n\n", |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
############################################################################### |
48
|
|
|
|
|
|
|
# |
49
|
|
|
|
|
|
|
# new() |
50
|
|
|
|
|
|
|
# |
51
|
|
|
|
|
|
|
# Simple constructor inheriting from Pod::Simple::Wiki. |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
sub new { |
54
|
|
|
|
|
|
|
|
55
|
27
|
|
|
27
|
1
|
49
|
my $class = shift; |
56
|
27
|
|
|
|
|
102
|
my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); |
57
|
27
|
|
|
|
|
58
|
$self->{_tags} = $tags; |
58
|
|
|
|
|
|
|
|
59
|
27
|
|
|
|
|
48
|
bless $self, $class; |
60
|
27
|
|
|
|
|
151
|
return $self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
############################################################################### |
64
|
|
|
|
|
|
|
# |
65
|
|
|
|
|
|
|
# _indent_item() |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
# Indents an "over-item" to the correct level. |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
sub _indent_item { |
70
|
|
|
|
|
|
|
|
71
|
37
|
|
|
37
|
|
41
|
my $self = shift; |
72
|
37
|
|
|
|
|
49
|
my $item_type = $_[0]; |
73
|
37
|
|
|
|
|
40
|
my $item_param = $_[1]; |
74
|
37
|
|
|
|
|
60
|
my $indent_level = $self->{_item_indent}; |
75
|
|
|
|
|
|
|
|
76
|
37
|
100
|
|
|
|
104
|
if ( $item_type eq 'bullet' ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
77
|
12
|
|
|
|
|
47
|
$self->_append( '*' x $indent_level . ' ' ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
elsif ( $item_type eq 'number' ) { |
80
|
12
|
|
|
|
|
45
|
$self->_append( '#' x $indent_level . ' ' ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Confluence doesn't have the equivalent of a list so we use a |
84
|
|
|
|
|
|
|
# bullet list with a bolded "item" as a workaround. |
85
|
|
|
|
|
|
|
elsif ( $item_type eq 'text' ) { |
86
|
13
|
|
|
|
|
51
|
$self->_append( '*' x $indent_level . ' *' ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
############################################################################### |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# _handle_text() |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
# Perform any necessary transforms on the text. This is mainly used to escape |
95
|
|
|
|
|
|
|
# inadvertent CamelCase words. |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
sub _handle_text { |
98
|
|
|
|
|
|
|
|
99
|
65
|
|
|
65
|
|
518
|
my $self = shift; |
100
|
65
|
|
|
|
|
115
|
my $text = $_[0]; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Split the text into tokens but maintain the whitespace |
103
|
65
|
|
|
|
|
293
|
my @tokens = split /(\s+)/, $text; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Escape any tokens here, if necessary. |
106
|
65
|
|
|
|
|
112
|
@tokens = map { s/([[{*_-])/\\$1/g; $_ } @tokens; |
|
265
|
|
|
|
|
376
|
|
|
265
|
|
|
|
|
614
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Rejoin the tokens and whitespace. |
109
|
65
|
|
|
|
|
309
|
$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
|
|
34
|
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
|
23
|
|
|
23
|
|
47
|
my $self = shift; |
134
|
23
|
|
|
|
|
38
|
my $indent_level = $self->{_item_indent}; |
135
|
|
|
|
|
|
|
|
136
|
23
|
100
|
|
|
|
100
|
if ( $self->{_in_over_block} ) { |
137
|
1
|
|
|
|
|
5
|
$self->_append( 'bq. ' ); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
############################################################################### |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
# _start_L() |
145
|
|
|
|
|
|
|
# |
146
|
|
|
|
|
|
|
# Handle the start of a link element. |
147
|
|
|
|
|
|
|
# |
148
|
|
|
|
|
|
|
sub _start_L { |
149
|
|
|
|
|
|
|
|
150
|
4
|
|
|
4
|
|
5
|
my $self = shift; |
151
|
4
|
|
|
|
|
5
|
my $link_attrs = shift; |
152
|
|
|
|
|
|
|
|
153
|
4
|
|
|
|
|
8
|
$self->{_link_attrs} = $link_attrs; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Ouput start of Confluence link and flush the _wiki_text buffer. |
156
|
4
|
|
|
|
|
14
|
$self->_output( '[' ); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
############################################################################### |
161
|
|
|
|
|
|
|
# |
162
|
|
|
|
|
|
|
# _end_L() |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
# Handle the end of a link element. |
165
|
|
|
|
|
|
|
# |
166
|
|
|
|
|
|
|
sub _end_L { |
167
|
|
|
|
|
|
|
|
168
|
4
|
|
|
4
|
|
6
|
my $self = shift; |
169
|
4
|
|
|
|
|
7
|
my $link_attrs = $self->{_link_attrs}; |
170
|
4
|
|
|
|
|
17
|
my $link_target = $link_attrs->{to}; |
171
|
4
|
|
|
|
|
8
|
my $link_section = $link_attrs->{section}; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# Handle links that are parsed as Pod links. |
174
|
4
|
100
|
|
|
|
9
|
if ( defined $link_section ) { |
175
|
1
|
|
|
|
|
2
|
$link_target = $link_section; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Remove quotes around link name. |
178
|
1
|
|
|
|
|
4
|
$self->{_wiki_text} =~ s/^"//; |
179
|
1
|
|
|
|
|
4
|
$self->{_wiki_text} =~ s/"$//; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# Only write [text|link] if text and link are different. |
183
|
4
|
100
|
|
|
|
13
|
if ( $self->{_wiki_text} ne $link_target ) { |
184
|
1
|
|
|
|
|
15
|
$self->_append( "|$link_target]" ); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
else { |
187
|
3
|
|
|
|
|
49
|
$self->_append( "]" ); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
__END__ |