line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################### |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This file copyright (c) 2009 by Randy J. Ray, all rights reserved |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copying and distribution are permitted under the terms of the Artistic |
6
|
|
|
|
|
|
|
# License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php) or |
7
|
|
|
|
|
|
|
# the GNU LGPL (http://www.opensource.org/licenses/lgpl-2.1.php). |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
############################################################################### |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Description: A sub-class of Text::Textile::Plaintext that plugs in a |
12
|
|
|
|
|
|
|
# PostScript formatter in place of the plain-text one. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Functions: new |
15
|
|
|
|
|
|
|
# textile |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# Libraries: HTML::FormatPS |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# Global Consts: $VERSION |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
############################################################################### |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Text::Textile::PostScript; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
1553
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
26
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
27
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
28
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
66
|
|
29
|
1
|
|
|
1
|
|
6
|
use subs qw(new textile); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
30
|
1
|
|
|
1
|
|
49
|
use base qw(Exporter Text::Textile::Plaintext); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
197
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Scalar::Util qw(blessed reftype); |
33
|
|
|
|
|
|
|
require HTML::FormatPS; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$VERSION = '0.101'; |
36
|
|
|
|
|
|
|
$VERSION = eval $VERSION; ## no critic |
37
|
|
|
|
|
|
|
@EXPORT = (); |
38
|
|
|
|
|
|
|
@EXPORT_OK = qw(textile); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
############################################################################### |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
# Sub Name: new |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# Description: Look for "formatter" arguments, and/or create a PS-based |
45
|
|
|
|
|
|
|
# formatter before relegating to the parent-class |
46
|
|
|
|
|
|
|
# constructor. |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# Arguments: NAME IN/OUT TYPE DESCRIPTION |
49
|
|
|
|
|
|
|
# $class in scalar Class we are blessing into |
50
|
|
|
|
|
|
|
# %args in hash Additional arguments |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# Returns: object reference, dies if given bad "formatter" data |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
############################################################################### |
55
|
|
|
|
|
|
|
sub new |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
my ($class, %args) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if ($args{formatter}) |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
if (!blessed $args{formatter}) |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
die __PACKAGE__ . "::new: Argument to 'formatter' must be an " . |
64
|
|
|
|
|
|
|
'object or a hash reference, stopped' |
65
|
|
|
|
|
|
|
unless (reftype($args{formatter}) eq 'HASH'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$args{formatter} = HTML::FormatPS->new(%{$args{formatter}}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else |
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
$args{formatter} = HTML::FormatPS->new(PaperSize => 'Letter'); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$class->SUPER::new(%args); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
############################################################################### |
79
|
|
|
|
|
|
|
# |
80
|
|
|
|
|
|
|
# Sub Name: textile |
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
# Description: A wrapper around the parent-class version, so that this |
83
|
|
|
|
|
|
|
# can be properly exported. |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# Arguments: NAME IN/OUT TYPE DESCRIPTION |
86
|
|
|
|
|
|
|
# $self in ref If present, an object of this |
87
|
|
|
|
|
|
|
# class. If not present, a |
88
|
|
|
|
|
|
|
# throw-away one is created. |
89
|
|
|
|
|
|
|
# $content in scalar Content to be converted to |
90
|
|
|
|
|
|
|
# plain text. |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# Returns: return value from SUPER::textile |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
############################################################################### |
95
|
|
|
|
|
|
|
sub textile |
96
|
|
|
|
|
|
|
{ |
97
|
|
|
|
|
|
|
my ($self, $content) = @_; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
unless (blessed $self && $self->isa('Text::Textile::PostScript')) |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
$content = $self; |
102
|
|
|
|
|
|
|
$self = __PACKAGE__->new(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$self->SUPER::textile($content); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Text::Textile::PostScript - Generate PostScript output from Textile mark-up |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use Text::Textile::PostScript qw(textile); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $textile = <
|
119
|
|
|
|
|
|
|
h1. Heading |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
A _simple_ demonstration of Textile markup. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
* One |
124
|
|
|
|
|
|
|
* Two |
125
|
|
|
|
|
|
|
* Three |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
"More information":http://www.textism.com/tools/textile is available. |
128
|
|
|
|
|
|
|
EOT |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Procedural interface: |
131
|
|
|
|
|
|
|
my $postscript = textile($textile); |
132
|
|
|
|
|
|
|
print $postscript; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Object-oriented interface |
135
|
|
|
|
|
|
|
my $ttps = Text::Textile::RTF->new(); |
136
|
|
|
|
|
|
|
$postscript = $ttps->process($textile); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 DESCRIPTION |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
B is a sub-class of B that |
141
|
|
|
|
|
|
|
produces PostScript output instead of plain text. See |
142
|
|
|
|
|
|
|
L for more detail. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 METHODS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This class only defines the following two methods. It inherits everything else |
147
|
|
|
|
|
|
|
from B. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=over 4 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item new([%args]) |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Create a new instance of this class. This constructor calls the super-class |
154
|
|
|
|
|
|
|
constructor after handling the C parameter and setting up an |
155
|
|
|
|
|
|
|
instance of B to pass to the parent. This method only handles |
156
|
|
|
|
|
|
|
the following parameter: |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over 8 |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item formatter($obj|$hashref) |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Specify either a pre-created instance of B (or a suitable |
163
|
|
|
|
|
|
|
sub-class) or a hash-reference of parameters to pass to the constructor when |
164
|
|
|
|
|
|
|
creating one. If this parameter is not present, an object is created with the |
165
|
|
|
|
|
|
|
default parameters (as according to B). The exception to this |
166
|
|
|
|
|
|
|
is that the default paper-size in B is "A4", whereas this |
167
|
|
|
|
|
|
|
module defaults paper size to "Letter". See L for details on |
168
|
|
|
|
|
|
|
the options available to the constructor. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=back |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
See documentation of the new() method in L for |
173
|
|
|
|
|
|
|
additional recognized parameters. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item textile($textile) |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This method is defined in this class so that it can be imported and used |
178
|
|
|
|
|
|
|
procedurally, as textile() is used in either B or |
179
|
|
|
|
|
|
|
B itself. It renders the Textile mark-up in C<$textile> to HTML, |
180
|
|
|
|
|
|
|
then renders the resulting HTML tree into PostScript. It returns the PostScript |
181
|
|
|
|
|
|
|
content as a single string. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 BUGS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
188
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at |
189
|
|
|
|
|
|
|
L. I |
190
|
|
|
|
|
|
|
will be notified, and then you'll automatically be notified of progress on your |
191
|
|
|
|
|
|
|
bug as I make changes. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 SUPPORT |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=over 4 |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
L |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
L |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item * CPAN Ratings |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
L |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item * Search CPAN |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
L |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * Source code on GitHub |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
L |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=back |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This file and the code within are copyright (c) 2009 by Randy J. Ray. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Copying and distribution are permitted under the terms of the Artistic |
224
|
|
|
|
|
|
|
License 2.0 (L) or |
225
|
|
|
|
|
|
|
the GNU LGPL 2.1 (L). |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 SEE ALSO |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L, L, L, |
230
|
|
|
|
|
|
|
L. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 AUTHOR |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Randy J. Ray C<< >> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=cut |