4 Pod::Simple - framework for parsing Pod
12 Pod::Simple is a Perl library for parsing text in the Pod ("plain old
13 documentation") markup language that is typically used for writing
14 documentation for Perl and for Perl modules. The Pod format is explained
15 in the L<perlpod|perlpod> man page; the most common formatter is called
18 Pod formatters can use Pod::Simple to parse Pod documents into produce
19 renderings of them in plain ASCII, in HTML, or in any number of other
20 formats. Typically, such formatters will be subclasses of Pod::Simple,
21 and so they will inherit its methods, like C<parse_file>.
23 If you're reading this document just because you have a Pod-processing
24 subclass that you want to use, this document (plus the documentation for
25 the subclass) is probably all you'll need to read.
27 If you're reading this document because you want to write a formatter
28 subclass, continue reading this document, and then read
29 L<Pod::Simple::Subclassing>, and then possibly even read L<perlpodspec>
30 (some of which is for parser-writers, but much of which is notes to
40 =item C<< $parser = I<SomeClass>->new(); >>
42 This returns a new parser object, where I<C<SomeClass>> is a subclass
45 =item C<< $parser->output_fh( *OUT ); >>
47 This sets the filehandle that C<$parser>'s output will be written to.
48 You can pass C<*STDOUT>, otherwise you should probably do something
51 my $outfile = "output.txt";
52 open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!";
53 $parser->output_fh(*TXTOUT);
55 ...before you call one of the C<< $parser->parse_I<whatever> >> methods.
57 =item C<< $parser->output_string( \$somestring ); >>
59 This sets the string that C<$parser>'s output will be sent to,
60 instead of any filehandle.
63 =item C<< $parser->parse_file( I<$some_filename> ); >>
65 =item C<< $parser->parse_file( *INPUT_FH ); >>
67 This reads the Pod content of the file (or filehandle) that you specify,
68 and processes it with that C<$parser> object, according to however
69 C<$parser>'s class works, and according to whatever parser options you
70 have set up for this C<$parser> object.
72 =item C<< $parser->parse_string_document( I<$all_content> ); >>
74 This works just like C<parse_file> except that it reads the Pod
75 content not from a file, but from a string that you have already
78 =item C<< $parser->parse_lines( I<...@lines...>, undef ); >>
80 This processes the lines in C<@lines> (where each list item must be a
81 defined value, and must contain exactly one line of content -- so no
82 items like C<"foo\nbar"> are allowed). The final C<undef> is used to
83 indicate the end of document being parsed.
85 The other C<parser_I<whatever>> methods are meant to be called only once
86 per C<$parser> object; but C<parse_lines> can be called as many times per
87 C<$parser> object as you want, as long as the last call (and only
88 the last call) ends with an C<undef> value.
91 =item C<< $parser->content_seen >>
93 This returns true only if there has been any real content seen
97 =item C<< I<SomeClass>->filter( I<$filename> ); >>
99 =item C<< I<SomeClass>->filter( I<*INPUT_FH> ); >>
101 =item C<< I<SomeClass>->filter( I<\$document_content> ); >>
103 This is a shortcut method for creating a new parser object, setting the
104 output handle to STDOUT, and then processing the specified file (or
105 filehandle, or in-memory document). This is handy for one-liners like
108 perl -MPod::Simple::Text -e "Pod::Simple::Text->filter('thingy.pod')"
114 =head1 SECONDARY METHODS
116 Some of these methods might be of interest to general users, as
117 well as of interest to formatter-writers.
119 Note that the general pattern here is that the accessor-methods
120 read the attribute's value with C<< $value = $parser->I<attribute> >>
121 and set the attribute's value with
122 C<< $parser->I<attribute>(I<newvalue>) >>. For each accessor, I typically
123 only mention one syntax or another, based on which I think you are actually
129 =item C<< $parser->no_whining( I<SOMEVALUE> ) >>
131 If you set this attribute to a true value, you will suppress the
132 parser's complaints about irregularities in the Pod coding. By default,
133 this attribute's value is false, meaning that irregularities will
136 Note that turning this attribute to true won't suppress one or two kinds
137 of complaints about rarely occurring unrecoverable errors.
140 =item C<< $parser->no_errata_section( I<SOMEVALUE> ) >>
142 If you set this attribute to a true value, you will stop the parser from
143 generating a "POD ERRORS" section at the end of the document. By
144 default, this attribute's value is false, meaning that an errata section
145 will be generated, as necessary.
148 =item C<< $parser->complain_stderr( I<SOMEVALUE> ) >>
150 If you set this attribute to a true value, it will send reports of
151 parsing errors to STDERR. By default, this attribute's value is false,
152 meaning that no output is sent to STDERR.
154 Note that errors can be noted in an errata section, or sent to STDERR,
155 or both, or neither. So don't think that turning on C<complain_stderr>
156 will turn off C<no_errata_section> or vice versa -- these are
157 independent attributes.
160 =item C<< $parser->source_filename >>
162 This returns the filename that this parser object was set to read from.
165 =item C<< $parser->doc_has_started >>
167 This returns true if C<$parser> has read from a source, and has seen
171 =item C<< $parser->source_dead >>
173 This returns true if C<$parser> has read from a source, and come to the
181 This is just a beta release -- there are a good number of things still
182 left to do. Notably, support for EBCDIC platforms is still half-done,
188 L<Pod::Simple::Subclassing>
192 L<perlpodspec|perlpodspec>
194 L<Pod::Escapes|Pod::Escapes>
199 =head1 COPYRIGHT AND DISCLAIMERS
201 Copyright (c) 2002 Sean M. Burke. All rights reserved.
203 This library is free software; you can redistribute it and/or modify it
204 under the same terms as Perl itself.
206 This program is distributed in the hope that it will be useful, but
207 without any warranty; without even the implied warranty of
208 merchantability or fitness for a particular purpose.
212 Original author: Sean M. Burke C<sburke@cpan.org>
218 =item * Allison Randal C<allison@perl.org>
220 =item * Hans Dieter Pearcey C<hdp@cpan.org>