.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Pod::Simple::Subclassing 3perl" .TH Pod::Simple::Subclassing 3perl "2011-09-26" "perl v5.14.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Pod::Simple::Subclassing \-\- write a formatter as a Pod::Simple subclass .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& package Pod::SomeFormatter; \& use Pod::Simple; \& @ISA = qw(Pod::Simple); \& $VERSION = \*(Aq1.01\*(Aq; \& use strict; \& \& sub _handle_element_start { \& my($parser, $element_name, $attr_hash_r) = @_; \& ... \& } \& \& sub _handle_element_end { \& my($parser, $element_name) = @_; \& ... \& } \& \& sub _handle_text { \& my($parser, $text) = @_; \& ... \& } \& 1; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This document is about using Pod::Simple to write a Pod processor, generally a Pod formatter. If you just want to know about using an existing Pod formatter, instead see its documentation and see also the docs in Pod::Simple. .PP The zeroeth step in writing a Pod formatter is to make sure that there isn't already a decent one in \s-1CPAN\s0. See , and run a search on the name of the format you want to render to. Also consider joining the Pod People list http://lists.perl.org/showlist.cgi?name=pod\-people and asking whether anyone has a formatter for that format \*(-- maybe someone cobbled one together but just hasn't released it. .PP The first step in writing a Pod processor is to read perlpodspec, which contains notes information on writing a Pod parser (which has been largely taken care of by Pod::Simple), but also a lot of requirements and recommendations for writing a formatter. .PP The second step is to actually learn the format you're planning to format to \*(-- or at least as much as you need to know to represent Pod, which probably isn't much. .PP The third step is to pick which of Pod::Simple's interfaces you want to use \*(-- the basic interface via Pod::Simple or Pod::Simple::Methody is event-based, sort of like HTML::Parser's interface, or sort of like XML::Parser's \*(L"Handlers\*(R" interface), but Pod::Simple::PullParser provides a token-stream interface, sort of like HTML::TokeParser's interface; Pod::Simple::SimpleTree provides a simple tree interface, rather like XML::Parser's \*(L"Tree\*(R" interface. Users familiar with XML-handling will find one of these styles relatively familiar; but if you would be even more at home with \s-1XML\s0, there are classes that produce an \s-1XML\s0 representation of the Pod stream, notably Pod::Simple::XMLOutStream; you can feed the output of such a class to whatever \s-1XML\s0 parsing system you are most at home with. .PP The last step is to write your code based on how the events (or tokens, or tree-nodes, or the \s-1XML\s0, or however you're parsing) will map to constructs in the output format. Also sure to consider how to escape text nodes containing arbitrary text, and also what to do with text nodes that represent preformatted text (from verbatim sections). .SH "Events" .IX Header "Events" \&\s-1TODO\s0 intro... mention that events are supplied for implicits, like for missing >'s .PP In the following section, we use \s-1XML\s0 to represent the event structure associated with a particular construct. That is, \s-1TODO\s0 .ie n .IP """$parser\->_handle_element_start( \f(CIelement_name\f(CW, \f(CIattr_hashref\f(CW )""" 4 .el .IP "\f(CW$parser\->_handle_element_start( \f(CIelement_name\f(CW, \f(CIattr_hashref\f(CW )\fR" 4 .IX Item "$parser->_handle_element_start( element_name, attr_hashref )" .PD 0 .ie n .IP """$parser\->_handle_element_end( \f(CIelement_name\f(CW )""" 4 .el .IP "\f(CW$parser\->_handle_element_end( \f(CIelement_name\f(CW )\fR" 4 .IX Item "$parser->_handle_element_end( element_name )" .ie n .IP """$parser\->_handle_text( \f(CItext_string\f(CW )""" 4 .el .IP "\f(CW$parser\->_handle_text( \f(CItext_string\f(CW )\fR" 4 .IX Item "$parser->_handle_text( text_string )" .PD .PP \&\s-1TODO\s0 describe .IP "events with an element_name of Document" 4 .IX Item "events with an element_name of Document" Parsing a document produces this event structure: .Sp .Vb 3 \& \& ...all events... \& .Ve .Sp The value of the \fIstart_line\fR attribute will be the line number of the first Pod directive in the document. .Sp If there is no Pod in the given document, then the event structure will be this: .Sp .Vb 2 \& \& .Ve .Sp In that case, the value of the \fIstart_line\fR attribute will not be meaningful; under current implementations, it will probably be the line number of the last line in the file. .IP "events with an element_name of Para" 4 .IX Item "events with an element_name of Para" Parsing a plain (non-verbatim, non-directive, non-data) paragraph in a Pod document produces this event structure: .Sp .Vb 3 \& \& ...all events in this paragraph... \& .Ve .Sp The value of the \fIstart_line\fR attribute will be the line number of the start of the paragraph. .Sp For example, parsing this paragraph of Pod: .Sp .Vb 2 \& The value of the I attribute will be the \& line number of the start of the paragraph. .Ve .Sp produces this event structure: .Sp .Vb 8 \& \& The value of the \& \& start_line \& \& attribute will be the line number of the first Pod directive \& in the document. \& .Ve .IP "events with an element_name of B, C, F, or I." 4 .IX Item "events with an element_name of B, C, F, or I." Parsing a B<...> formatting code (or of course any of its semantically identical syntactic variants B<<\ ...\ >>, or B<<<<\ ...\ >>>>, etc.) produces this event structure: .Sp .Vb 3 \& \& ...stuff... \& .Ve .Sp Currently, there are no attributes conveyed. .Sp Parsing C, F, or I codes produce the same structure, with only a different element name. .Sp If your parser object has been set to accept other formatting codes, then they will be presented like these B/C/F/I codes \*(-- i.e., without any attributes. .IP "events with an element_name of S" 4 .IX Item "events with an element_name of S" Normally, parsing an S<...> sequence produces this event structure, just as if it were a B/C/F/I code: .Sp .Vb 3 \& \& ...stuff... \& .Ve .Sp However, Pod::Simple (and presumably all derived parsers) offers the \&\f(CW\*(C`nbsp_for_S\*(C'\fR option which, if enabled, will suppress all S events, and instead change all spaces in the content to non-breaking spaces. This is intended for formatters that output to a format that has no code that means the same as S<...>, but which has a code/character that means non-breaking space. .IP "events with an element_name of X" 4 .IX Item "events with an element_name of X" Normally, parsing an X<...> sequence produces this event structure, just as if it were a B/C/F/I code: .Sp .Vb 3 \& \& ...stuff... \& .Ve .Sp However, Pod::Simple (and presumably all derived parsers) offers the \&\f(CW\*(C`nix_X_codes\*(C'\fR option which, if enabled, will suppress all X events and ignore their content. For formatters/processors that don't use X events, this is presumably quite useful. .IP "events with an element_name of L" 4 .IX Item "events with an element_name of L" Because the L<...> is the most complex construct in the language, it should not surprise you that the events it generates are the most complex in the language. Most of complexity is hidden away in the attribute values, so for those of you writing a Pod formatter that produces a non-hypertextual format, you can just ignore the attributes and treat an L event structure like a formatting element that (presumably) doesn't actually produce a change in formatting. That is, the content of the L event structure (as opposed to its attributes) is always what text should be displayed. .Sp There are, at first glance, three kinds of L links: \s-1URL\s0, man, and pod. .Sp When a L<\fIsome_url\fR> code is parsed, it produces this event structure: .Sp .Vb 3 \& \& that_url \& .Ve .Sp The \f(CW\*(C`type="url"\*(C'\fR attribute is always specified for this type of L code. .Sp For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& http://www.perl.com/CPAN/authors/ \& .Ve .Sp When a L<\fImanpage(section)\fR> code is parsed (and these are fairly rare and not terribly useful), it produces this event structure: .Sp .Vb 3 \& \& manpage(section) \& .Ve .Sp The \f(CW\*(C`type="man"\*(C'\fR attribute is always specified for this type of L code. .Sp For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& crontab(5) \& .Ve .Sp In the rare cases where a man page link has a specified, that text appears in a \fIsection\fR attribute. For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp will produce this event structure: .Sp .Vb 3 \& \& "ENVIRONMENT" in crontab(5) \& .Ve .Sp In the rare case where the Pod document has code like L<\fIsometext\fR|\fImanpage(section)\fR>, then the \fIsometext\fR will appear as the content of the element, the \fImanpage(section)\fR text will appear only as the value of the \fIto\fR attribute, and there will be no \&\f(CW\*(C`content\-implicit="yes"\*(C'\fR attribute (whose presence means that the Pod parser had to infer what text should appear as the link text \*(-- as opposed to cases where that attribute is absent, which means that the Pod parser did \&\fInot\fR have to infer the link text, because that L code explicitly specified some link text.) .Sp For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp will produce this event structure: .Sp .Vb 3 \& \& hell itself! \& .Ve .Sp The last type of L structure is for links to/within Pod documents. It is the most complex because it can have a \fIto\fR attribute, \fIor\fR a \&\fIsection\fR attribute, or both. The \f(CW\*(C`type="pod"\*(C'\fR attribute is always specified for this type of L code. .Sp In the most common case, the simple case of a L code produces this event structure: .Sp .Vb 3 \& \& podpage \& .Ve .Sp For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& Net::Ping \& .Ve .Sp In cases where there is link-text explicitly specified, it is to be found in the content of the element (and not the attributes), just as with the L<\fIsometext\fR|\fImanpage(section)\fR> case discussed above. For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& Perl Error Messages \& .Ve .Sp In cases of links to a section in the current Pod document, there is a \fIsection\fR attribute instead of a \fIto\fR attribute. For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& "Member Data" \& .Ve .Sp As another example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& the various attributes \& .Ve .Sp In cases of links to a section in a different Pod document, there are both a \fIsection\fR attribute and a to attribute. For example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& "Basic BLOCKs and Switch Statements" in perlsyn \& .Ve .Sp As another example, this Pod source: .Sp .Vb 1 \& L .Ve .Sp produces this event structure: .Sp .Vb 3 \& \& SWITCH statements \& .Ve .Sp Incidentally, note that we do not distinguish between these syntaxes: .Sp .Vb 4 \& L \& L<"Member Data"> \& L \& L [deprecated syntax] .Ve .Sp That is, they all produce the same event structure, namely: .Sp .Vb 3 \& \& "Member Data" \& .Ve .IP "events with an element_name of E or Z" 4 .IX Item "events with an element_name of E or Z" While there are Pod codes E<...> and Z<>, these \&\fIdo not\fR produce any E or Z events \*(-- that is, there are no such events as E or Z. .IP "events with an element_name of Verbatim" 4 .IX Item "events with an element_name of Verbatim" When a Pod verbatim paragraph (\s-1AKA\s0 \*(L"codeblock\*(R") is parsed, it produces this event structure: .Sp .Vb 3 \& \& ...text... \& .Ve .Sp The value of the \fIstart_line\fR attribute will be the line number of the first line of this verbatim block. The \fIxml:space\fR attribute is always present, and always has the value \*(L"preserve\*(R". .Sp The text content will have tabs already expanded. .IP "events with an element_name of head1 .. head4" 4 .IX Item "events with an element_name of head1 .. head4" When a \*(L"=head1 ...\*(R" directive is parsed, it produces this event structure: .Sp .Vb 3 \& \& ...stuff... \& .Ve .Sp For example, a directive consisting of this: .Sp .Vb 1 \& =head1 Options to C et al. .Ve .Sp will produce this event structure: .Sp .Vb 7 \& \& Options to \& \& new \& \& et al. \& .Ve .Sp \&\*(L"=head2\*(R" thru \*(L"=head4\*(R" directives are the same, except for the element names in the event structure. .IP "events with an element_name of over-bullet" 4 .IX Item "events with an element_name of over-bullet" When an \*(L"=over ... =back\*(R" block is parsed where the items are a bulleted list, it will produce this event structure: .Sp .Vb 6 \& \& \& ...Stuff... \& \& ...more item\-bullets... \& .Ve .Sp The value of the \fIindent\fR attribute is whatever value is after the \&\*(L"=over\*(R" directive, as in \*(L"=over 8\*(R". If no such value is specified in the directive, then the \fIindent\fR attribute has the value \*(L"4\*(R". .Sp For example, this Pod source: .Sp .Vb 1 \& =over \& \& =item * \& \& Stuff \& \& =item * \& \& Bar I! \& \& =back .Ve .Sp produces this event structure: .Sp .Vb 8 \& \& \& Stuff \& \& \& Bar baz! \& \& .Ve .IP "events with an element_name of over-number" 4 .IX Item "events with an element_name of over-number" When an \*(L"=over ... =back\*(R" block is parsed where the items are a numbered list, it will produce this event structure: .Sp .Vb 6 \& \& \& ...Stuff... \& \& ...more item\-number... \& .Ve .Sp This is like the \*(L"over-bullet\*(R" event structure; but note that the contents are \*(L"item-number\*(R" instead of \*(L"item-bullet\*(R", and note that they will have a \*(L"number\*(R" attribute, which some formatters/processors may ignore (since, for example, there's no need for it in \s-1HTML\s0 when producing an \*(L"<\s-1UL\s0><\s-1LI\s0>......\*(R" structure), but which any processor may use. .Sp Note that the values for the \fInumber\fR attributes of \*(L"item-number\*(R" elements in a given \*(L"over-number\*(R" area \fIwill\fR start at 1 and go up by one each time. If the Pod source doesn't follow that order (even though it really should should!), whatever numbers it has will be ignored (with the correct values being put in the \fInumber\fR attributes), and an error message might be issued to the user. .IP "events with an element_name of over-text" 4 .IX Item "events with an element_name of over-text" These events are are somewhat unlike the other over\-* structures, as far as what their contents are. When an \*(L"=over ... =back\*(R" block is parsed where the items are a list of text \*(L"subheadings\*(R", it will produce this event structure: .Sp .Vb 8 \& \& \& ...stuff... \& \& ...stuff (generally Para or Verbatim elements)... \& \& ...more item\-text and/or stuff... \& .Ve .Sp The \fIindent\fR attribute is as with the other over\-* events. .Sp For example, this Pod source: .Sp .Vb 1 \& =over \& \& =item Foo \& \& Stuff \& \& =item Bar I! \& \& Quux \& \& =back .Ve .Sp produces this event structure: .Sp .Vb 10 \& \& \& Foo \& \& \& Stuff \& \& \& Bar \& \& baz \& \& ! \& \& \& Quux \& \& .Ve .IP "events with an element_name of over-block" 4 .IX Item "events with an element_name of over-block" These events are are somewhat unlike the other over\-* structures, as far as what their contents are. When an \*(L"=over ... =back\*(R" block is parsed where there are no items, it will produce this event structure: .Sp .Vb 3 \& \& ...stuff (generally Para or Verbatim elements)... \& .Ve .Sp The \fIindent\fR attribute is as with the other over\-* events. .Sp For example, this Pod source: .Sp .Vb 1 \& =over \& \& For cutting off our trade with all parts of the world \& \& For transporting us beyond seas to be tried for pretended offenses \& \& He is at this time transporting large armies of foreign mercenaries to \& complete the works of death, desolation and tyranny, already begun with \& circumstances of cruelty and perfidy scarcely paralleled in the most \& barbarous ages, and totally unworthy the head of a civilized nation. \& \& =cut .Ve .Sp will produce this event structure: .Sp .Vb 11 \& \& \& For cutting off our trade with all parts of the world \& \& \& For transporting us beyond seas to be tried for pretended offenses \& \& \& He is at this time transporting large armies of [...more text...] \& \& .Ve .IP "events with an element_name of item-bullet" 4 .IX Item "events with an element_name of item-bullet" See \*(L"events with an element_name of over-bullet\*(R", above. .IP "events with an element_name of item-number" 4 .IX Item "events with an element_name of item-number" See \*(L"events with an element_name of over-number\*(R", above. .IP "events with an element_name of item-text" 4 .IX Item "events with an element_name of item-text" See \*(L"events with an element_name of over-text\*(R", above. .IP "events with an element_name of for" 4 .IX Item "events with an element_name of for" \&\s-1TODO\s0... .IP "events with an element_name of Data" 4 .IX Item "events with an element_name of Data" \&\s-1TODO\s0... .SH "More Pod::Simple Methods" .IX Header "More Pod::Simple Methods" Pod::Simple provides a lot of methods that aren't generally interesting to the end user of an existing Pod formatter, but some of which you might find useful in writing a Pod formatter. They are listed below. The first several methods (the accept_* methods) are for declaring the capabilities of your parser, notably what \f(CW\*(C`=for \f(CItargetname\f(CW\*(C'\fR sections it's interested in, what extra N<...> codes it accepts beyond the ones described in the \fIperlpod\fR. .ie n .IP """$parser\->accept_targets( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->accept_targets( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->accept_targets( SOMEVALUE )" As the parser sees sections like: .Sp .Vb 1 \& =for html .Ve .Sp or .Sp .Vb 1 \& =begin html \& \& \& \& =end html .Ve .Sp \&...the parser will ignore these sections unless your subclass has specified that it wants to see sections targetted to \*(L"html\*(R" (or whatever the formatter name is). .Sp If you want to process all sections, even if they're not targetted for you, call this before you start parsing: .Sp .Vb 1 \& $parser\->accept_targets(\*(Aq*\*(Aq); .Ve .ie n .IP """$parser\->accept_targets_as_text( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->accept_targets_as_text( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->accept_targets_as_text( SOMEVALUE )" This is like accept_targets, except that it specifies also that the content of sections for this target should be treated as Pod text even if the target name in "=for \fItargetname\fR\*(L" doesn't start with a \*(R":". .Sp At time of writing, I don't think you'll need to use this. .ie n .IP """$parser\->accept_codes( \f(CICodename\f(CW, \f(CICodename\f(CW... )""" 4 .el .IP "\f(CW$parser\->accept_codes( \f(CICodename\f(CW, \f(CICodename\f(CW... )\fR" 4 .IX Item "$parser->accept_codes( Codename, Codename... )" This tells the parser that you accept additional formatting codes, beyond just the standard ones (I B C L F S X, plus the two weird ones you don't actually see in the parse tree, Z and E). For example, to also accept codes \*(L"N\*(R", \*(L"R\*(R", and \*(L"W\*(R": .Sp .Vb 1 \& $parser\->accept_codes( qw( N R W ) ); .Ve .Sp \&\fB\s-1TODO:\s0 document how this interacts with =extend, and long element names\fR .ie n .IP """$parser\->accept_directive_as_data( \f(CIdirective_name\f(CW )""" 4 .el .IP "\f(CW$parser\->accept_directive_as_data( \f(CIdirective_name\f(CW )\fR" 4 .IX Item "$parser->accept_directive_as_data( directive_name )" .PD 0 .ie n .IP """$parser\->accept_directive_as_verbatim( \f(CIdirective_name\f(CW )""" 4 .el .IP "\f(CW$parser\->accept_directive_as_verbatim( \f(CIdirective_name\f(CW )\fR" 4 .IX Item "$parser->accept_directive_as_verbatim( directive_name )" .ie n .IP """$parser\->accept_directive_as_processed( \f(CIdirective_name\f(CW )""" 4 .el .IP "\f(CW$parser\->accept_directive_as_processed( \f(CIdirective_name\f(CW )\fR" 4 .IX Item "$parser->accept_directive_as_processed( directive_name )" .PD In the unlikely situation that you need to tell the parser that you will accept additional directives (\*(L"=foo\*(R" things), you need to first set the parset to treat its content as data (i.e., not really processed at all), or as verbatim (mostly just expanding tabs), or as processed text (parsing formatting codes like B<...>). .Sp For example, to accept a new directive \*(L"=method\*(R", you'd presumably use: .Sp .Vb 1 \& $parser\->accept_directive_as_processed("method"); .Ve .Sp so that you could have Pod lines like: .Sp .Vb 1 \& =method I<$whatever> thing B .Ve .Sp Making up your own directives breaks compatibility with other Pod formatters, in a way that using "=for \fItarget\fR ..." lines doesn't; however, you may find this useful if you're making a Pod superset format where you don't need to worry about compatibility. .ie n .IP """$parser\->nbsp_for_S( \f(CIBOOLEAN\f(CW );""" 4 .el .IP "\f(CW$parser\->nbsp_for_S( \f(CIBOOLEAN\f(CW );\fR" 4 .IX Item "$parser->nbsp_for_S( BOOLEAN );" Setting this attribute to a true value (and by default it is false) will turn \*(L"S<...>\*(R" sequences into sequences of words separated by \&\f(CW\*(C`\exA0\*(C'\fR (non-breaking space) characters. For example, it will take this: .Sp .Vb 1 \& I like S, don\*(Aqt you? .Ve .Sp and treat it as if it were: .Sp .Vb 1 \& I like DutchEappleEpie, don\*(Aqt you? .Ve .Sp This is handy for output formats that don't have anything quite like an \&\*(L"S<...>\*(R" code, but which do have a code for non-breaking space. .Sp There is currently no method for going the other way; but I can probably provide one upon request. .ie n .IP """$parser\->version_report()""" 4 .el .IP "\f(CW$parser\->version_report()\fR" 4 .IX Item "$parser->version_report()" This returns a string reporting the \f(CW$VERSION\fR value from your module (and its classname) as well as the \f(CW$VERSION\fR value of Pod::Simple. Note that perlpodspec requires output formats (wherever possible) to note this detail in a comment in the output format. For example, for some kind of \s-1SGML\s0 output format: .Sp .Vb 1 \& print OUT "version_report, "\en \-\->"; .Ve .ie n .IP """$parser\->pod_para_count()""" 4 .el .IP "\f(CW$parser\->pod_para_count()\fR" 4 .IX Item "$parser->pod_para_count()" This returns the count of Pod paragraphs seen so far. .ie n .IP """$parser\->line_count()""" 4 .el .IP "\f(CW$parser\->line_count()\fR" 4 .IX Item "$parser->line_count()" This is the current line number being parsed. But you might find the \&\*(L"line_number\*(R" event attribute more accurate, when it is present. .ie n .IP """$parser\->nix_X_codes( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->nix_X_codes( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->nix_X_codes( SOMEVALUE )" This attribute, when set to a true value (and it is false by default) ignores any \*(L"X<...>\*(R" sequences in the document being parsed. Many formats don't actually use the content of these codes, so have no reason to process them. .ie n .IP """$parser\->merge_text( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->merge_text( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->merge_text( SOMEVALUE )" This attribute, when set to a true value (and it is false by default) makes sure that only one event (or token, or node) will be created for any single contiguous sequence of text. For example, consider this somewhat contrived example: .Sp .Vb 1 \& I just LOVE Z<>hotE<32>apple pie! .Ve .Sp When that is parsed and events are about to be called on it, it may actually seem to be four different text events, one right after another: one event for \*(L"I just \s-1LOVE\s0 \*(R", one for \*(L"hot\*(R", one for \*(L" \*(R", and one for \&\*(L"apple pie!\*(R". But if you have merge_text on, then you're guaranteed that it will be fired as one text event: \*(L"I just \s-1LOVE\s0 hot apple pie!\*(R". .ie n .IP """$parser\->code_handler( \f(CICODE_REF\f(CW )""" 4 .el .IP "\f(CW$parser\->code_handler( \f(CICODE_REF\f(CW )\fR" 4 .IX Item "$parser->code_handler( CODE_REF )" This specifies code that should be called when a code line is seen (i.e., a line outside of the Pod). Normally this is undef, meaning that no code should be called. If you provide a routine, it should start out like this: .Sp .Vb 4 \& sub get_code_line { # or whatever you\*(Aqll call it \& my($line, $line_number, $parser) = @_; \& ... \& } .Ve .Sp Note, however, that sometimes the Pod events aren't processed in exactly the same order as the code lines are \*(-- i.e., if you have a file with Pod, then code, then more Pod, sometimes the code will be processed (via whatever you have code_handler call) before the all of the preceding Pod has been processed. .ie n .IP """$parser\->cut_handler( \f(CICODE_REF\f(CW )""" 4 .el .IP "\f(CW$parser\->cut_handler( \f(CICODE_REF\f(CW )\fR" 4 .IX Item "$parser->cut_handler( CODE_REF )" This is just like the code_handler attribute, except that it's for \&\*(L"=cut\*(R" lines, not code lines. The same caveats apply. \*(L"=cut\*(R" lines are unlikely to be interesting, but this is included for completeness. .ie n .IP """$parser\->whine( \f(CIlinenumber\f(CW, \f(CIcomplaint string\f(CW )""" 4 .el .IP "\f(CW$parser\->whine( \f(CIlinenumber\f(CW, \f(CIcomplaint string\f(CW )\fR" 4 .IX Item "$parser->whine( linenumber, complaint string )" This notes a problem in the Pod, which will be reported to in the \*(L"Pod Errors\*(R" section of the document and/or send to \s-1STDERR\s0, depending on the values of the attributes \f(CW\*(C`no_whining\*(C'\fR, \f(CW\*(C`no_errata_section\*(C'\fR, and \&\f(CW\*(C`complain_stderr\*(C'\fR. .ie n .IP """$parser\->scream( \f(CIlinenumber\f(CW, \f(CIcomplaint string\f(CW )""" 4 .el .IP "\f(CW$parser\->scream( \f(CIlinenumber\f(CW, \f(CIcomplaint string\f(CW )\fR" 4 .IX Item "$parser->scream( linenumber, complaint string )" This notes an error like \f(CW\*(C`whine\*(C'\fR does, except that it is not suppressible with \f(CW\*(C`no_whining\*(C'\fR. This should be used only for very serious errors. .ie n .IP """$parser\->source_dead(1)""" 4 .el .IP "\f(CW$parser\->source_dead(1)\fR" 4 .IX Item "$parser->source_dead(1)" This aborts parsing of the current document, by switching on the flag that indicates that \s-1EOF\s0 has been seen. In particularly drastic cases, you might want to do this. It's rather nicer than just calling \&\f(CW\*(C`die\*(C'\fR! .ie n .IP """$parser\->hide_line_numbers( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->hide_line_numbers( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->hide_line_numbers( SOMEVALUE )" Some subclasses that indiscriminately dump event attributes (well, except for ones beginning with \*(L"~\*(R") can use this object attribute for refraining to dump the \*(L"start_line\*(R" attribute. .ie n .IP """$parser\->no_whining( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->no_whining( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->no_whining( SOMEVALUE )" This attribute, if set to true, will suppress reports of non-fatal error messages. The default value is false, meaning that complaints \&\fIare\fR reported. How they get reported depends on the values of the attributes \f(CW\*(C`no_errata_section\*(C'\fR and \f(CW\*(C`complain_stderr\*(C'\fR. .ie n .IP """$parser\->no_errata_section( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->no_errata_section( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->no_errata_section( SOMEVALUE )" This attribute, if set to true, will suppress generation of an errata section. The default value is false \*(-- i.e., an errata section will be generated. .ie n .IP """$parser\->complain_stderr( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->complain_stderr( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->complain_stderr( SOMEVALUE )" This attribute, if set to true will send complaints to \s-1STDERR\s0. The default value is false \*(-- i.e., complaints do not go to \s-1STDERR\s0. .ie n .IP """$parser\->bare_output( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->bare_output( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->bare_output( SOMEVALUE )" Some formatter subclasses use this as a flag for whether output should have prologue and epilogue code omitted. For example, setting this to true for an \s-1HTML\s0 formatter class should omit the \&\*(L"......\*(R" prologue and the \&\*(L"\*(R" epilogue. .Sp If you want to set this to true, you should probably also set \&\f(CW\*(C`no_whining\*(C'\fR or at least \f(CW\*(C`no_errata_section\*(C'\fR to true. .ie n .IP """$parser\->preserve_whitespace( \f(CISOMEVALUE\f(CW )""" 4 .el .IP "\f(CW$parser\->preserve_whitespace( \f(CISOMEVALUE\f(CW )\fR" 4 .IX Item "$parser->preserve_whitespace( SOMEVALUE )" If you set this attribute to a true value, the parser will try to preserve whitespace in the output. This means that such formatting conventions as two spaces after periods will be preserved by the parser. This is primarily useful for output formats that treat whitespace as significant (such as text or *roff, but not \s-1HTML\s0). .SH "SEE ALSO" .IX Header "SEE ALSO" Pod::Simple \*(-- event-based Pod-parsing framework .PP Pod::Simple::Methody \*(-- like Pod::Simple, but each sort of event calls its own method (like \f(CW\*(C`start_head3\*(C'\fR) .PP Pod::Simple::PullParser \*(-- a Pod-parsing framework like Pod::Simple, but with a token-stream interface .PP Pod::Simple::SimpleTree \*(-- a Pod-parsing framework like Pod::Simple, but with a tree interface .PP Pod::Simple::Checker \*(-- a simple Pod::Simple subclass that reads documents, and then makes a plaintext report of any errors found in the document .PP Pod::Simple::DumpAsXML \*(-- for dumping Pod documents as tidily indented \s-1XML\s0, showing each event on its own line .PP Pod::Simple::XMLOutStream \*(-- dumps a Pod document as \s-1XML\s0 (without introducing extra whitespace as Pod::Simple::DumpAsXML does). .PP Pod::Simple::DumpAsText \*(-- for dumping Pod documents as tidily indented text, showing each event on its own line .PP Pod::Simple::LinkSection \*(-- class for objects representing the values of the \s-1TODO\s0 and \s-1TODO\s0 attributes of L<...> elements .PP Pod::Escapes \*(-- the module the Pod::Simple uses for evaluating E<...> content .PP Pod::Simple::Text \*(-- a simple plaintext formatter for Pod .PP Pod::Simple::TextContent \*(-- like Pod::Simple::Text, but makes no effort for indent or wrap the text being formatted .PP Pod::Simple::HTML \*(-- a simple \s-1HTML\s0 formatter for Pod .PP perlpod .PP perlpodspec .PP perldoc .SH "SUPPORT" .IX Header "SUPPORT" Questions or discussion about \s-1POD\s0 and Pod::Simple should be sent to the pod\-people@perl.org mail list. Send an empty email to pod\-people\-subscribe@perl.org to subscribe. .PP This module is managed in an open GitHub repository, http://github.com/theory/pod\-simple/ . Feel free to fork and contribute, or to clone git://github.com/theory/pod\-simple.git and send patches! .PP Patches against Pod::Simple are welcome. Please send bug reports to . .SH "COPYRIGHT AND DISCLAIMERS" .IX Header "COPYRIGHT AND DISCLAIMERS" Copyright (c) 2002 Sean M. Burke. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. .SH "AUTHOR" .IX Header "AUTHOR" Pod::Simple was created by Sean M. Burke . But don't bother him, he's retired. .PP Pod::Simple is maintained by: .IP "\(bu" 4 Allison Randal \f(CW\*(C`allison@perl.org\*(C'\fR .IP "\(bu" 4 Hans Dieter Pearcey \f(CW\*(C`hdp@cpan.org\*(C'\fR .IP "\(bu" 4 David E. Wheeler \f(CW\*(C`dwheeler@cpan.org\*(C'\fR