1Pod::Text(3) User Contributed Perl Documentation Pod::Text(3)
2
3
4
6 Pod::Text - Convert POD data to formatted text
7
9 use Pod::Text;
10 my $parser = Pod::Text->new (sentence => 1, width => 78);
11
12 # Read POD from STDIN and write to STDOUT.
13 $parser->parse_from_filehandle;
14
15 # Read POD from file.pod and write to file.txt.
16 $parser->parse_from_file ('file.pod', 'file.txt');
17
19 Pod::Text is a module that can convert documentation in the POD format
20 (the preferred language for documenting Perl) into formatted text. It
21 uses no special formatting controls or codes whatsoever, and its output
22 is therefore suitable for nearly any device.
23
24 As a derived class from Pod::Simple, Pod::Text supports the same
25 methods and interfaces. See Pod::Simple for all the details; briefly,
26 one creates a new parser with "Pod::Text->new()" and then normally
27 calls parse_file().
28
29 new() can take options, in the form of key/value pairs, that control
30 the behavior of the parser. The currently recognized options are:
31
32 alt If set to a true value, selects an alternate output format that,
33 among other things, uses a different heading style and marks
34 "=item" entries with a colon in the left margin. Defaults to
35 false.
36
37 code
38 If set to a true value, the non-POD parts of the input file will be
39 included in the output. Useful for viewing code documented with
40 POD blocks with the POD rendered and the code left intact.
41
42 errors
43 How to report errors. "die" says to throw an exception on any POD
44 formatting error. "stderr" says to report errors on standard
45 error, but not to throw an exception. "pod" says to include a POD
46 ERRORS section in the resulting documentation summarizing the
47 errors. "none" ignores POD errors entirely, as much as possible.
48
49 The default is "pod".
50
51 indent
52 The number of spaces to indent regular text, and the default
53 indentation for "=over" blocks. Defaults to 4.
54
55 loose
56 If set to a true value, a blank line is printed after a "=head1"
57 heading. If set to false (the default), no blank line is printed
58 after "=head1", although one is still printed after "=head2". This
59 is the default because it's the expected formatting for manual
60 pages; if you're formatting arbitrary text documents, setting this
61 to true may result in more pleasing output.
62
63 margin
64 The width of the left margin in spaces. Defaults to 0. This is
65 the margin for all text, including headings, not the amount by
66 which regular text is indented; for the latter, see the indent
67 option. To set the right margin, see the width option.
68
69 nourls
70 Normally, L<> formatting codes with a URL but anchor text are
71 formatted to show both the anchor text and the URL. In other
72 words:
73
74 L<foo|http://example.com/>
75
76 is formatted as:
77
78 foo <http://example.com/>
79
80 This option, if set to a true value, suppresses the URL when anchor
81 text is given, so this example would be formatted as just "foo".
82 This can produce less cluttered output in cases where the URLs are
83 not particularly important.
84
85 quotes
86 Sets the quote marks used to surround C<> text. If the value is a
87 single character, it is used as both the left and right quote.
88 Otherwise, it is split in half, and the first half of the string is
89 used as the left quote and the second is used as the right quote.
90
91 This may also be set to the special value "none", in which case no
92 quote marks are added around C<> text.
93
94 sentence
95 If set to a true value, Pod::Text will assume that each sentence
96 ends in two spaces, and will try to preserve that spacing. If set
97 to false, all consecutive whitespace in non-verbatim paragraphs is
98 compressed into a single space. Defaults to false.
99
100 stderr
101 Send error messages about invalid POD to standard error instead of
102 appending a POD ERRORS section to the generated output. This is
103 equivalent to setting "errors" to "stderr" if "errors" is not
104 already set. It is supported for backward compatibility.
105
106 utf8
107 By default, Pod::Text uses the same output encoding as the input
108 encoding of the POD source (provided that Perl was built with
109 PerlIO; otherwise, it doesn't encode its output). If this option
110 is given, the output encoding is forced to UTF-8.
111
112 Be aware that, when using this option, the input encoding of your
113 POD source should be properly declared unless it's US-ASCII.
114 Pod::Simple will attempt to guess the encoding and may be
115 successful if it's Latin-1 or UTF-8, but it will produce warnings.
116 Use the "=encoding" command to declare the encoding. See
117 perlpod(1) for more information.
118
119 width
120 The column at which to wrap text on the right-hand side. Defaults
121 to 76.
122
123 The standard Pod::Simple method parse_file() takes one argument naming
124 the POD file to read from. By default, the output is sent to "STDOUT",
125 but this can be changed with the output_fh() method.
126
127 The standard Pod::Simple method parse_from_file() takes up to two
128 arguments, the first being the input file to read POD from and the
129 second being the file to write the formatted output to.
130
131 You can also call parse_lines() to parse an array of lines or
132 parse_string_document() to parse a document already in memory. As with
133 parse_file(), parse_lines() and parse_string_document() default to
134 sending their output to "STDOUT" unless changed with the output_fh()
135 method.
136
137 To put the output from any parse method into a string instead of a file
138 handle, call the output_string() method instead of output_fh().
139
140 See Pod::Simple for more specific details on the methods available to
141 all derived parsers.
142
144 Bizarre space in item
145 Item called without tag
146 (W) Something has gone wrong in internal "=item" processing. These
147 messages indicate a bug in Pod::Text; you should never see them.
148
149 Can't open %s for reading: %s
150 (F) Pod::Text was invoked via the compatibility mode pod2text()
151 interface and the input file it was given could not be opened.
152
153 Invalid errors setting "%s"
154 (F) The "errors" parameter to the constructor was set to an unknown
155 value.
156
157 Invalid quote specification "%s"
158 (F) The quote specification given (the "quotes" option to the
159 constructor) was invalid. A quote specification must be either one
160 character long or an even number (greater than one) characters
161 long.
162
163 POD document had syntax errors
164 (F) The POD document being formatted had syntax errors and the
165 "errors" option was set to "die".
166
168 Encoding handling assumes that PerlIO is available and does not work
169 properly if it isn't. The "utf8" option is therefore not supported
170 unless Perl is built with PerlIO support.
171
173 If Pod::Text is given the "utf8" option, the encoding of its output
174 file handle will be forced to UTF-8 if possible, overriding any
175 existing encoding. This will be done even if the file handle is not
176 created by Pod::Text and was passed in from outside. This maintains
177 consistency regardless of PERL_UNICODE and other settings.
178
179 If the "utf8" option is not given, the encoding of its output file
180 handle will be forced to the detected encoding of the input POD, which
181 preserves whatever the input text is. This ensures backward
182 compatibility with earlier, pre-Unicode versions of this module,
183 without large numbers of Perl warnings.
184
185 This is not ideal, but it seems to be the best compromise. If it
186 doesn't work for you, please let me know the details of how it broke.
187
189 This is a replacement for an earlier Pod::Text module written by Tom
190 Christiansen. It has a revamped interface, since it now uses
191 Pod::Simple, but an interface roughly compatible with the old
192 Pod::Text::pod2text() function is still available. Please change to
193 the new calling convention, though.
194
195 The original Pod::Text contained code to do formatting via termcap
196 sequences, although it wasn't turned on by default and it was
197 problematic to get it to work at all. This rewrite doesn't even try to
198 do that, but a subclass of it does. Look for Pod::Text::Termcap.
199
201 Russ Allbery <rra@cpan.org>, based very heavily on the original
202 Pod::Text by Tom Christiansen <tchrist@mox.perl.com> and its conversion
203 to Pod::Parser by Brad Appleton <bradapp@enteract.com>. Sean Burke's
204 initial conversion of Pod::Man to use Pod::Simple provided much-needed
205 guidance on how to use Pod::Simple.
206
208 Copyright 1999-2002, 2004, 2006, 2008-2009, 2012-2016, 2018 Russ
209 Allbery <rra@cpan.org>
210
211 This program is free software; you may redistribute it and/or modify it
212 under the same terms as Perl itself.
213
215 Pod::Simple, Pod::Text::Termcap, perlpod(1), pod2text(1)
216
217 The current version of this module is always available from its web
218 site at <https://www.eyrie.org/~eagle/software/podlators/>. It is also
219 part of the Perl core distribution as of 5.6.0.
220
221
222
223perl v5.28.0 2018-05-07 Pod::Text(3)