line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Templer::Plugin::Textile - A simple textile-formatting plugin. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=cut |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This class implements a formatter plugin for C which allows |
11
|
|
|
|
|
|
|
pages to be written using textile. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This allows input such as this to be executed: |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=for example begin |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Title: This is my page |
18
|
|
|
|
|
|
|
format: textile |
19
|
|
|
|
|
|
|
---- |
20
|
|
|
|
|
|
|
**Bold** |
21
|
|
|
|
|
|
|
_italic_ |
22
|
|
|
|
|
|
|
Content! |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=for example end |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 LICENSE |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
31
|
|
|
|
|
|
|
under the terms of either: |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
a) the GNU General Public License as published by the Free Software |
34
|
|
|
|
|
|
|
Foundation; either version 2, or (at your option) any later version, |
35
|
|
|
|
|
|
|
or |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
b) the Perl "Artistic License". |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 AUTHOR |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Steve Kemp |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Copyright (C) 2012-2015 Steve Kemp . |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This library is free software. You can modify and or distribute it under |
52
|
|
|
|
|
|
|
the same terms as Perl itself. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
11
|
|
|
11
|
|
7049
|
use strict; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
330
|
|
62
|
11
|
|
|
11
|
|
49
|
use warnings; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
1987
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Templer::Plugin::Textile; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 new |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Constructor. No arguments are supported/expected. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub new |
76
|
|
|
|
|
|
|
{ |
77
|
5
|
|
|
5
|
1
|
10
|
my ( $proto, %supplied ) = (@_); |
78
|
5
|
|
33
|
|
|
19
|
my $class = ref($proto) || $proto; |
79
|
|
|
|
|
|
|
|
80
|
5
|
|
|
|
|
9
|
my $self = {}; |
81
|
5
|
|
|
|
|
6
|
bless( $self, $class ); |
82
|
5
|
|
|
|
|
9
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 available |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This plugin is available if we've got the L module. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub available |
93
|
|
|
|
|
|
|
{ |
94
|
2
|
|
|
2
|
1
|
5
|
my $str = "use Text::Textile;"; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
## no critic (Eval) |
97
|
2
|
|
|
1
|
|
93
|
eval($str); |
|
1
|
|
|
1
|
|
730
|
|
|
1
|
|
|
|
|
48905
|
|
|
1
|
|
|
|
|
26
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
98
|
|
|
|
|
|
|
## use critic |
99
|
|
|
|
|
|
|
|
100
|
2
|
50
|
|
|
|
9
|
return ( $@ ? undef : 1 ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 format |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Format the given text. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub format |
111
|
|
|
|
|
|
|
{ |
112
|
1
|
|
|
1
|
1
|
3
|
my ( $self, $str, $data ) = (@_); |
113
|
|
|
|
|
|
|
|
114
|
1
|
50
|
|
|
|
4
|
if ( $self->available() ) |
115
|
|
|
|
|
|
|
{ |
116
|
1
|
|
|
|
|
3
|
Text::Textile::textile($str); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
|
|
0
|
warn |
121
|
|
|
|
|
|
|
"Textile formatting disabled as the Text::Textile module isn't present.\n"; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
$str; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Templer::Plugin::Factory->new() |
128
|
|
|
|
|
|
|
->register_formatter( "textile", "Templer::Plugin::Textile" ); |