line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Simple::Wiki::Muse; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Pod::Simple::Wiki::Muse - A class for creating Pod to Muse filters. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright 2015, Marco Pessotto melmothx@gmail.com |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Documentation after __END__ |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# perltidy with the following options: -mbl=2 -pt=0 -nola |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
21
|
use Pod::Simple::Wiki; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
128
|
|
16
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
80
|
|
17
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
159
|
|
18
|
4
|
|
|
4
|
|
19
|
use vars qw(@ISA $VERSION); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2743
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
@ISA = qw(Pod::Simple::Wiki); |
22
|
|
|
|
|
|
|
$VERSION = '0.20'; |
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", |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
'' => "** ", |
39
|
|
|
|
|
|
|
'' => "\n\n", |
40
|
|
|
|
|
|
|
'' => "*** ", |
41
|
|
|
|
|
|
|
'' => "\n\n", |
42
|
|
|
|
|
|
|
'' => "**** ", |
43
|
|
|
|
|
|
|
'' => "\n\n", |
44
|
|
|
|
|
|
|
'' => "***** ", |
45
|
|
|
|
|
|
|
'' => "\n\n", |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
############################################################################### |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
# new() |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# Simple constructor inheriting from Pod::Simple::Wiki. |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
sub new { |
55
|
|
|
|
|
|
|
|
56
|
31
|
|
|
31
|
1
|
47
|
my $class = shift; |
57
|
31
|
|
|
|
|
105
|
my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); |
58
|
31
|
|
|
|
|
67
|
$self->{_tags} = $tags; |
59
|
|
|
|
|
|
|
|
60
|
31
|
|
|
|
|
42
|
bless $self, $class; |
61
|
31
|
|
|
|
|
91
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
############################################################################### |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
# _indent_item() |
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
# Indents an "over-item" to the correct level. |
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
sub _indent_item { |
71
|
45
|
|
|
45
|
|
75
|
my ($self, $item_type, $param) = @_; |
72
|
|
|
|
|
|
|
# print "Indent level is $self->{_item_indent}\n"; |
73
|
45
|
|
|
|
|
73
|
my $indent_level = $self->{_item_indent} - 1; |
74
|
45
|
100
|
|
|
|
120
|
if ( $item_type eq 'bullet' ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
75
|
14
|
|
|
|
|
54
|
$self->_append( "\n" . ' ' x $indent_level . ' - ' ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif ( $item_type eq 'number' ) { |
78
|
14
|
|
|
|
|
54
|
$self->_append( "\n" . ' ' x $indent_level . ' 1. ' ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ( $item_type eq 'text' ) { |
81
|
17
|
|
|
|
|
64
|
$self->_append( "\n" . ' ' x $indent_level . ' ' ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
############################################################################### |
87
|
|
|
|
|
|
|
# |
88
|
|
|
|
|
|
|
# _handle_text() |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
# Perform any necessary transforms on the text. This is mainly used to escape |
91
|
|
|
|
|
|
|
# inadvertent CamelCase words. |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
sub _handle_text { |
94
|
|
|
|
|
|
|
|
95
|
80
|
|
|
80
|
|
574
|
my $self = shift; |
96
|
80
|
|
|
|
|
108
|
my $text = $_[0]; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Only escape words in paragraphs |
99
|
80
|
100
|
|
|
|
167
|
if ( not $self->{_in_Para} ) { |
100
|
49
|
|
|
|
|
69
|
$self->{_wiki_text} .= $text; |
101
|
49
|
|
|
|
|
117
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Split the text into tokens but maintain the whitespace |
105
|
31
|
|
|
|
|
142
|
my @tokens = split /(\s+)/, $text; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Portme: |
108
|
|
|
|
|
|
|
# Escape any tokens here, if necessary. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Rejoin the tokens and whitespace. |
111
|
31
|
|
|
|
|
126
|
$self->{_wiki_text} .= join '', @tokens; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
############################################################################### |
116
|
|
|
|
|
|
|
# |
117
|
|
|
|
|
|
|
# Functions to deal with =over ... =back regions for |
118
|
|
|
|
|
|
|
# |
119
|
|
|
|
|
|
|
# Bulleted lists |
120
|
|
|
|
|
|
|
# Numbered lists |
121
|
|
|
|
|
|
|
# Text lists |
122
|
|
|
|
|
|
|
# Block lists |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
sub _end_item_text { |
125
|
17
|
|
|
17
|
|
22
|
my $self = shift; |
126
|
17
|
|
|
|
|
27
|
my $indent_level = $self->{_item_indent} - 1; |
127
|
17
|
|
|
|
|
48
|
$self->_output( " :: "); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
############################################################################### |
133
|
|
|
|
|
|
|
# |
134
|
|
|
|
|
|
|
# _start_Para() |
135
|
|
|
|
|
|
|
# |
136
|
|
|
|
|
|
|
# Special handling for paragraphs that are part of an "over" block. |
137
|
|
|
|
|
|
|
# |
138
|
|
|
|
|
|
|
sub _start_Para { |
139
|
|
|
|
|
|
|
|
140
|
28
|
|
|
28
|
|
38
|
my $self = shift; |
141
|
28
|
|
|
|
|
45
|
my $indent_level = $self->{_item_indent} - 1; |
142
|
28
|
100
|
|
|
|
97
|
if ( $self->{_in_over_block} ) { |
143
|
1
|
|
|
|
|
5
|
$self->_append( "\n" . ' ' x $indent_level . ' ' ); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub _start_L { |
148
|
6
|
|
|
6
|
|
10
|
my ($self, $link_attrs) = @_; |
149
|
|
|
|
|
|
|
# print Dumper($link_attrs); |
150
|
|
|
|
|
|
|
# reset the buffer |
151
|
6
|
|
|
|
|
20
|
$self->_output(''); |
152
|
6
|
|
|
|
|
11
|
$self->{_link_attr} = $link_attrs; |
153
|
6
|
|
|
|
|
10
|
my $link_target = $link_attrs->{to}; |
154
|
6
|
|
|
|
|
10
|
my $link_section = $link_attrs->{section}; |
155
|
6
|
100
|
|
|
|
13
|
$link_target = '' if( !defined($link_target)); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Handle links that are parsed as Pod links. |
158
|
6
|
100
|
|
|
|
13
|
if ( defined $link_section ) { |
159
|
2
|
|
|
|
|
6
|
$link_target = "$link_target#$link_section"; |
160
|
|
|
|
|
|
|
} |
161
|
6
|
|
|
|
|
48
|
$self->_append( "[[$link_target][" ); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub _end_L { |
165
|
6
|
|
|
6
|
|
7
|
my $self = shift; |
166
|
6
|
|
|
|
|
15
|
$self->_output(']]'); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
__END__ |