Pod::Si...lassing(3pm)

πŸ¦‹ Pod::Simple::Subclassing(3pm) β€” Perl Programmers Reference Guide πŸ¦‹

okay so bestie, this is the manual page for Pod::Simple::Subclassing, and it's literally your whole guide to writing a Pod formatter. grab a snack, we're doing this πŸ’…


✨ NAME ✨

Pod::Simple::Subclassing β€” write a formatter as a Pod::Simple subclass


πŸŽ€ SYNOPSIS πŸŽ€

  package Pod::SomeFormatter;
  use Pod::Simple;
  @ISA = qw(Pod::Simple);
  $VERSION = '1.01';
  use strict;

  sub _handle_element_start {
    my($parser, $element_name, $attr_hash_r) = @_;
    ...
  }

  sub _handle_element_end {
    my($parser, $element_name, $attr_hash_r) = @_;
    # NOTE: $attr_hash_r is only present when $element_name is "over" or "begin"
    # The remaining code excerpts will mostly ignore this $attr_hash_r, as it is
    # mostly useless. It is documented where "over-*" and "begin" events are
    # documented.
    ...
  }

  sub _handle_text {
    my($parser, $text) = @_;
    ...
  }
  1;

πŸ’– DESCRIPTION πŸ’–

So this doc is all about using Pod::Simple to write a Pod processor β€” and like, generally that means a Pod formatter. If you're just here because you wanna use an existing Pod formatter, no shade, but go read that formatter's own docs instead, and also peep the docs in Pod::Simple.

🌸 The zeroeth step 🌸

The zeroeth step in writing a Pod formatter is to make sure there isn't already a decent one on CPAN. Like, check first, bestie 😭. Look at http://search.cpan.org/, and run a search on the name of the format you wanna render to. Also lowkey consider joining the Pod People list at http://lists.perl.org/showlist.cgi?name=pod-people and asking whether anyone has a formatter for that format β€” because maybe someone totally cobbled one together and just hasn't released it yet. it happens. 🫢

πŸ¦‹ The first step πŸ¦‹

The first step in writing a Pod processor is to read perlpodspec. It's got the info on writing a Pod parser (which, ngl, Pod::Simple has largely taken care of for you), but it also has a ton of requirements and recommendations for writing a formatter. so read it, periodt.

πŸŽ€ The second step πŸŽ€

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. don't stress. πŸ’…

πŸ‘‘ The third step πŸ‘‘

The third step is to pick which of Pod::Simple's interfaces you want to use:

  • Pod::Simple β€” the basic Pod::Simple interface that uses _handle_element_start(), _handle_element_end() and _handle_text().
  • Pod::Simple::Methody β€” the Pod::Simple::Methody interface is event-based, similar to that of HTML::Parser or XML::Parser's "Handlers".
  • Pod::Simple::PullParser β€” Pod::Simple::PullParser provides a token-stream interface, sort of like HTML::TokeParser's interface.
  • Pod::Simple::SimpleTree β€” Pod::Simple::SimpleTree provides a simple tree interface, rather like XML::Parser's "Tree" interface. Users familiar with XML handling will be comfortable with this interface. Users interested in outputting XML should look into the modules that produce an XML representation of the Pod stream, notably Pod::Simple::XMLOutStream; you can feed the output of such a class to whatever XML parsing system you are most at home with.

🌈 The last step 🌈

The last step is to write your code based on how the events (or tokens, or tree-nodes, or the XML, or however you're parsing) will map to constructs in the output format. Also be sure to consider how to escape text nodes containing arbitrary text, and what to do with text nodes that represent preformatted text (from verbatim sections). iconic behavior only ✨


πŸ”₯ Events πŸ”₯

TODO intro... mention that events are supplied for implicits, like for missing >'s

In the following section, we use XML to represent the event structure associated with a particular construct. That is, an opening tag represents the element start, the attributes of that opening tag are the attributes given to the callback, and the closing tag represents the end element.

Three callback methods must be supplied by a class extending Pod::Simple to receive the corresponding event:

  • "$parser->_handle_element_start( element_name, attr_hashref )"
  • "$parser->_handle_element_end( element_name )"
  • "$parser->_handle_text( text_string )"

Here's the comprehensive list of values you can expect as element_name in your implementation of _handle_element_start and _handle_element_end::

⭐ events with an element_name of Document

Parsing a document produces this event structure:

  <Document start_line="543">
    ...all events...
  </Document>

The value of the start_line attribute will be the line number of the first Pod directive in the document.

If there is no Pod in the given document, then the event structure will be this:

  <Document contentless="1" start_line="543">
  </Document>

In that case, the value of the start_line attribute will not be meaningful; under current implementations, it will probably be the line number of the last line in the file. yeah. it's giving "we tried" πŸ’€

⭐ 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:

    <Para start_line="543">
      ...all events in this paragraph...
    </Para>

The value of the start_line attribute will be the line number of the start of the paragraph.

For example, parsing this paragraph of Pod:

  The value of the I<start_line> attribute will be the
  line number of the start of the paragraph.

produces this event structure:

    <Para start_line="129">
      The value of the
      <I>
        start_line
      </I>
      attribute will be the line number of the first Pod directive
      in the document.
    </Para>

⭐ 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:

      <B>
        ...stuff...
      </B>

Currently, there are no attributes conveyed. (yes, none. empty. a vibe.)

Parsing C, F, or I codes produce the same structure, with only a different element name.

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.

⭐ 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:

      <S>
        ...stuff...
      </S>

However, Pod::Simple (and presumably all derived parsers) offers the "nbsp_for_S" 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. slay πŸ’…

⭐ 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:

      <X>
        ...stuff...
      </X>

However, Pod::Simple (and presumably all derived parsers) offers the "nix_X_codes" 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. ngl, very handy 🫢

⭐ 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. main character energy, but make it attributes πŸ‘‘

There are, at first glance, three kinds of L links: URL, man, and pod.

When a L<some_url> code is parsed, it produces this event structure:

  <L content-implicit="yes" raw="that_url" to="that_url" type="url">
    that_url
  </L>

The "type="url"" attribute is always specified for this type of L code.

For example, this Pod source:

  L<http://www.perl.com/CPAN/authors/>

produces this event structure:

  <L content-implicit="yes" raw="http://www.perl.com/CPAN/authors/" to="http://www.perl.com/CPAN/authors/" type="url">
    http://www.perl.com/CPAN/authors/
  </L>

When a L<manpage(section)> code is parsed (and these are fairly rare and not terribly useful), it produces this event structure:

  <L content-implicit="yes" raw="manpage(section)" to="manpage(section)" type="man">
    manpage(section)
  </L>

The "type="man"" attribute is always specified for this type of L code.

For example, this Pod source:

  L<crontab(5)>

produces this event structure:

  <L content-implicit="yes" raw="crontab(5)" to="crontab(5)" type="man">
    crontab(5)
  </L>

In the rare cases where a man page link has a section specified, that text appears in a section attribute. For example, this Pod source:

  L<crontab(5)/"ENVIRONMENT">

will produce this event structure:

  <L content-implicit="yes" raw="crontab(5)/&quot;ENVIRONMENT&quot;" section="ENVIRONMENT" to="crontab(5)" type="man">
    "ENVIRONMENT" in crontab(5)
  </L>

In the rare case where the Pod document has code like L<sometext|manpage(section)>, then the sometext will appear as the content of the element, the manpage(section) text will appear only as the value of the to attribute, and there will be no "content-implicit="yes"" 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 not have to infer the link text, because that L code explicitly specified some link text.)

For example, this Pod source:

  L<hell itself!|crontab(5)>

will produce this event structure:

  <L raw="hell itself!|crontab(5)" to="crontab(5)" type="man">
    hell itself!
  </L>

The last type of L structure is for links to/within Pod documents. It is the most complex because it can have a to attribute, or a section attribute, or both. The "type="pod"" attribute is always specified for this type of L code.

In the most common case, the simple case of a L<podpage> code produces this event structure:

Okay so if the L<> doesn't spell out its own link text, the text is implicit β€” the event literally carries content-implicit="yes" and the target becomes the content. Like this Pod source:

L<Net::Ping>

gives you this event structure:

<L content-implicit="yes" raw="Net::Ping" to="Net::Ping" type="pod">
  Net::Ping
</L>

When the link text is explicitly spelled out, it lives in the content of the element, not in the attributes β€” exactly like the L<sometext|manpage(section)> case we already talked about. So this Pod source:

L<Perl Error Messages|perldiag>

produces:

<L raw="Perl Error Messages|perldiag" to="perldiag" type="pod">
  Perl Error Messages
</L>

Now, when you're linking to a section inside the current Pod document, there's a section attribute instead of a to attribute. Bestie, watch:

L</"Member Data">

becomes:

<L content-implicit="yes" raw="/&quot;Member Data&quot;" section="Member Data" type="pod">
  "Member Data"
</L>

And with explicit text:

L<the various attributes|/"Member Data">

becomes:

<L raw="the various attributes|/&quot;Member Data&quot;" section="Member Data" type="pod">
  the various attributes
</L>

When it's a section in a different Pod document, you get both a section attribute and a to attribute. Like:

L<perlsyn/"Basic BLOCKs and Switch Statements">

gives:

<L content-implicit="yes" raw="perlsyn/&quot;Basic BLOCKs and Switch Statements&quot;" section="Basic BLOCKs and Switch Statements" to="perlsyn" type="pod">
  "Basic BLOCKs and Switch Statements" in perlsyn
</L>

And with explicit text, this Pod source:

L<SWITCH statements|perlsyn/"Basic BLOCKs and Switch Statements">

gives:

<L raw="SWITCH statements|perlsyn/&quot;Basic BLOCKs and Switch Statements&quot;" section="Basic BLOCKs and Switch Statements" to="perlsyn" type="pod">
  SWITCH statements
</L>

Incidentally (and this is lowkey iconic), Pod::Simple does not distinguish between these syntaxes:

L</"Member Data">
L<"Member Data">
L</Member Data>
L<Member Data>    [deprecated syntax]

They all produce the same event structure (for the most part), namely:

<L content-implicit="yes" raw="$depends_on_syntax" section="Member Data" type="pod">
  &#34;Member Data&#34;
</L>

The raw attribute depends on what the raw content of the L<> actually is β€” which is exactly why the structure is the same only "for the most part". πŸ’…

If you haven't clocked it yet: raw holds the raw, original, unescaped content of the L<> formatting code. Beyond the examples above, peep this β€” the L<> formatting code:

L<click B<here>|page/About the C<-M> switch>

produces:

<L raw="click B<here>|page/About the C<-M> switch" section="About the -M switch" to="page" type="pod">
  click B<here>
</L>

Notice specifically that the formatting codes are present and unescaped inside raw. 🌸

Known bug alert πŸ›: there's a known bug in the raw attribute where any surrounding whitespace gets condensed into a single ' '. For example, given L< link>, raw will be " link".

events with an element_name of E or Z

So there are Pod codes E<...> and Z<>, right? But they don't produce any E or Z events β€” like, there are literally no such events as E or Z. That's just the whole vibe check. πŸ’€

events with an element_name of Verbatim

When a Pod verbatim paragraph (AKA a "codeblock") gets parsed, it produces this event structure:

<Verbatim start_line="543" xml:space="preserve">
  ...text...
</Verbatim>

The value of the start_line attribute is the line number of the first line of that verbatim block. The xml:space attribute is always present, and always has the value "preserve".

And the text content will have tabs already expanded. ✨

events with an element_name of head1 .. head4

When a =head1 ... directive gets parsed, it produces this event structure:

<head1>
  ...stuff...
</head1>

For example, a directive consisting of this:

=head1 Options to C<new> et al.

will produce this event structure:

<head1 start_line="543">
  Options to
  <C>
    new
  </C>
  et al.
</head1>

=head2 through =head4 directives are the same, except for the element names in the event structure. Simple as. 🫢

events with an element_name of encoding

In the default case, the events corresponding to =encoding directives are not emitted. They only get emitted if keep_encoding_directive is true. In that case they produce event structures like the "events with an element_name of head1 .. head4" ones up above. πŸ‘‘

events with an element_name of over-bullet

When an =over ... =back block is parsed where the items are a bulleted list, it produces this event structure:

<over-bullet indent="4" start_line="543">
  <item-bullet start_line="545">
    ...Stuff...
  </item-bullet>
  ...more item-bullets...
</over-bullet fake-closer="1">

The attribute fake-closer is only present if it's a true value; it is not present if it's a false value. It's shown in the example above just to illustrate where the attribute goes (in the closing tag). It signifies that the =over did not have a matching =back, and thus Pod::Simple had to create a fake closer. 😭

For example, this Pod source:

=over

=item *

Something

=back

Would produce an event structure that does not have the fake-closer attribute β€” whereas this Pod source:

=over

=item *

Gasp! An unclosed =over block!

would. The rest of the over-* examples won't demonstrate this attribute, but they all can have it. (See Pod::Checker's source for an example of this attribute being used. πŸ”)

The value of the indent attribute is whatever value comes after the =over directive, as in =over 8. If no such value is specified in the directive, then the indent attribute has the value "4".

For example, this Pod source:

=over

=item *

Stuff

=item *

Bar I<baz>!

=back

produces this event structure:

<over-bullet indent="4" start_line="10">
  <item-bullet start_line="12">
    Stuff
  </item-bullet>
  <item-bullet start_line="14">
    Bar <I>baz</I>!
  </item-bullet>
</over-bullet>

events with an element_name of over-number

When an =over ... =back block is parsed where the items are a numbered list, it produces this event structure:

<over-number indent="4" start_line="543">
  <item-number number="1" start_line="545">
    ...Stuff...
  </item-number>
  ...more item-number...
</over-bullet>

This is like the over-bullet event structure, but β€” heads up β€” the contents are item-number instead of item-bullet, and they'll have a number attribute, which some formatters/processors may ignore (since, for example, there's no need for it in HTML when producing an <UL><LI>...</LI>...</UL> structure), but which any processor may use.

Note that the values for the number attributes of item-number elements in a given over-number area will start at 1 and go up by one each time. If the Pod source doesn't follow that order (even though it really should!), whatever numbers it has will be ignored (with the correct values being put in the number attributes), and an error message might be issued to the user. πŸ™ˆ

events with an element_name of over-text

These events are somewhat unlike the other over-* structures, as far as what their contents are. When an =over ... =back block is parsed where the items are a list of text "subheadings", it produces this event structure:

<over-text indent="4" start_line="543">
  <item-text>
    ...stuff...
  </item-text>
  ...stuff (generally Para or Verbatim elements)...
  <item-text>
  ...more item-text and/or stuff...
</over-text>

The indent and fake-closer attributes are exactly as with the other over-* events.

For example, this Pod source:

=over

=item Foo

Stuff

=item Bar I<baz>!

Quux

=back

produces this event structure:

<over-text indent="4" start_line="20">
  <item-text start_line="22">
    Foo
  </item-text>
  <Para start_line="24">
    Stuff
  </Para>
  <item-text start_line="26">
    Bar
      <I>
        baz
      </I>
    !
  </item-text>
  <Para start_line="28">
    Quux
  </Para>
</over-text>

events with an element_name of over-block

These events are also somewhat unlike the other over-* structures, as far as what their contents are. When an =over ... =back block is parsed where there are no items, it produces this event structure:

<over-block indent="4" start_line="543">
  ...stuff (generally Para or Verbatim elements)...
</over-block>

The indent and fake-closer attributes are as with the other over-* events.

For example, this Pod source:

=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.

=back

will produce this event structure:

…and the paragraphs inside that over-block shake out like this, bestie πŸ’–

<over-block indent="4" start_line="2">
  <Para start_line="4">
    For cutting off our trade with all parts of the world
  </Para>
  <Para start_line="6">
    For transporting us beyond seas to be tried for pretended offenses
  </Para>
  <Para start_line="8">
    He is at this time transporting large armies of [...more text...]
  </Para>
</over-block>

Every <Para> gets its own little start_line moment, iconic πŸ’…


πŸ¦‹ events with an element_name of over-empty πŸ¦‹

Okay so heads up before anything else: these events are only triggered if parse_empty_lists() is set to a true value. Like, that's the vibe check, it's giving conditional ✨

These events are lowkey built different from the other over-* structures when it comes to what's actually inside them. When an =over ... =back block gets parsed and there's literally no content in it, it'll produce this event structure:

<over-empty indent="4" start_line="543">
</over-empty>

Look at it. It's empty. It said "no thoughts, head empty" and meant it 😭

The indent and fake-closer attributes work exactly as with the other over-* events β€” same rules, same energy, no cap 🫢

So like, for example, this Pod source right here:

=over

=over

=back

=back

will produce this event structure:

<over-block indent="4" start_line="1">
  <over-empty indent="4" start_line="3">
  </over-empty>
</over-block>

Now pay attention bestie because this is the cute plot twist πŸ‘‘ The outer =over is a block because it has no =items but still has content: the inner =over. The inner =over, in turn, is completely empty, and is treated as such. Main character behavior from the outer one, honestly.


πŸŽ€ events with an element_name of item-bullet πŸŽ€

See "events with an element_name of over-bullet", above. That's it, that's the whole thing, go read it πŸ’–


🌈 events with an element_name of item-number 🌈

See "events with an element_name of over-number", above. Same deal, bestie πŸ¦‹


🌸 events with an element_name of item-text 🌸

See "events with an element_name of over-text", above. Slay, you already know ✨


πŸ’œ events with an element_name of for πŸ’œ

TODO... β€” yeah that's literally all it says. It's giving unfinished homework, but we respect the honesty πŸ™ˆ


⭐ events with an element_name of Data ⭐

TODO... again. Same vibe, same mystery, we simply do not know yet πŸ’€

More Pod::Simple Methods πŸ’…

Okay so Pod::Simple has a ton of methods that are lowkey not that deep for anyone just using an existing Pod formatter β€” but ngl, if you're writing your own formatter, some of these are gonna be your whole personality. They're all listed below. And the first several (the accept_* squad) are all about declaring what your parser can handle β€” think: which =for targetname sections it actually cares about, and what extra N<...> codes it'll accept beyond the ones described in the perlpod. 🫢


$parser->accept_targets( SOMEVALUE )

So when the parser rolls up on sections like:

=for html  <img src="fig1.jpg">

or

=begin html

  <img src="fig1.jpg">

=end html

…bestie, it will literally ignore those sections unless your subclass has specified that it wants to see sections targeted to "html" (or whatever the formatter name is). Rude, but fair.

If you want to process all the sections β€” even the ones that aren't targeted at you β€” call this before you start parsing:

$parser->accept_targets('*');

$parser->accept_targets_as_text( SOMEVALUE )

This is like accept_targets, except it also specifies that the content of sections for this target should be treated as Pod text even if the target name in =for targetname doesn't start with a ":".

At time of writing, I don't think you'll need to use this. πŸ’€

$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 "N", "R", and "W":

$parser->accept_codes( qw( N R W ) );
TODO: document how this interacts with =extend, and long element names

$parser->accept_directive_as_data( directive_name )

$parser->accept_directive_as_verbatim( directive_name )

$parser->accept_directive_as_processed( directive_name )

In the unlikely situation that you need to tell the parser that you'll accept additional directives (the "=foo" type things), you first need to set the parser 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<...>). ✨

So for example, to accept a new directive "=method", you'd presumably use:

$parser->accept_directive_as_processed("method");

so that you could have Pod lines like:

=method I<$whatever> thing B<um>

Making up your own directives breaks compatibility with other Pod formatters β€” in a way that using "=for target ..." 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. πŸ‘‘

$parser->nbsp_for_S( BOOLEAN );

Setting this attribute to a true value (and by default it is false) will turn "S<...>" sequences into sequences of words separated by "\xA0" (non-breaking space) characters. For example, it will take this:

I like S<Dutch apple pie>, don't you?

and treat it as if it were:

I like DutchE<nbsp>appleE<nbsp>pie, don't you?

This is handy for output formats that don't have anything quite like an "S<...>" code, but which do have a code for non-breaking space. πŸŽ€

There is currently no method for going the other way; but I can probably provide one upon request. πŸ™ˆ

$parser->version_report()

This returns a string reporting the $VERSION value from your module (and its classname) as well as the $VERSION 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 SGML output format:

print OUT "<!-- \n", $parser->version_report, "\n -->";

$parser->pod_para_count()

This returns the count of Pod paragraphs seen so far. Counting era fr fr πŸ”’

$parser->line_count()

This is the current line number being parsed. But you might find the "line_number" event attribute more accurate, when it is present. πŸ‘€

$parser->nix_X_codes( SOMEVALUE )

This attribute, when set to a true value (and it is false by default) ignores any "X<...>" sequences in the document being parsed. Many formats don't actually use the content of these codes, so have no reason to process them. Slay, skip the X's. πŸ’…

$parser->keep_encoding_directive( SOMEVALUE )

This attribute, when set to a true value (it is false by default) will keep "=encoding" and its content in the event structure. Most formats don't actually need to process the content of an "=encoding" directive, even when this directive sets the encoding and the processor makes use of the encoding information. Indeed, it is possible to know the encoding without processing the directive content. πŸ¦‹

$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:

I just LOVE Z<>hotE<32>apple pie!

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 "I just LOVE ", one for "hot", one for " ", and one for "apple pie!". But if you have merge_text on, then you're guaranteed that it will be fired as one text event: "I just LOVE hot apple pie!". Main character energy: one event, no crumbs. ✨

$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:

sub get_code_line {  # or whatever you'll call it
  my($line, $line_number, $parser) = @_;
  ...
}

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 all of the preceding Pod has been processed. 😭 Ordering is giving chaos, so heads up.

$parser->cut_handler( CODE_REF )

This is just like the code_handler attribute, except that it's for "=cut" lines, not code lines. The same caveats apply. "=cut" lines are unlikely to be interesting, but this is included for completeness. 🫢

$parser->pod_handler( CODE_REF )

This is just like the code_handler attribute, except that it's for "=pod" lines, not code lines. The same caveats apply. "=pod" lines are unlikely to be interesting, but this is included for completeness. 🫢

$parser->whiteline_handler( CODE_REF )

This is just like the code_handler attribute, except that it's for lines that are seemingly blank but have whitespace (" " and/or "\t") on them, not code lines. The same caveats apply. These lines are unlikely to be interesting, but this is included for completeness. 🫢

$parser->whine( linenumber, complaint string )

This notes a problem in the Pod, which will be reported in the "Pod Errors" section of the document and/or sent to STDERR, depending on the values of the attributes "no_whining", "no_errata_section", and "complain_stderr". Basically a little grumble, not a full meltdown. 😀

$parser->scream( linenumber, complaint string )

This notes an error like whine does, except that it is not suppressible with "no_whining". This should be used only for very serious errors. Like, actual screaming. πŸ”₯

$parser->source_dead(1)

This aborts parsing of the current document, by switching on the flag that indicates that EOF has been seen. In particularly drastic cases, you might want to do this. It's rather nicer than just calling "die"! πŸ’€πŸ’–

$parser->hide_line_numbers( SOMEVALUE )

Some subclasses that indiscriminately dump event attributes (well, except for ones beginning with "~") can use this object attribute for refraining to dump the "start_line" attribute. Hidden line numbers, sneaky sneaky. πŸ™ˆ

$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 are reported. How they get reported depends on the values of the attributes "no_errata_section" and "complain_stderr". Shhh, no complaining. 🀫

$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. πŸ“

$parser->complain_stderr( SOMEVALUE )

This attribute, if set to true will send complaints to STDERR. The default value is false β€” i.e., complaints do not go to STDERR. πŸ—£οΈ

$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 HTML formatter class should omit the "<html><head><title>...</title><body>..." prologue and the "</body></html>" epilogue. πŸ‘‘

If you want to set this to true, you should probably also set "no_whining" or at least "no_errata_section" to true. Just saying. πŸ’…

$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 HTML). 🌸

$parser->parse_empty_lists( SOMEVALUE )

If this attribute is set to true, the parser will not ignore empty "=over"/"=back" blocks. The type of "=over" will be empty, documented above, "events with an element_name of over-empty". ✨

✨ SEE ALSO ✨

okay bestie, here's the whole Pod::Simple friend group β€” every single one, no skipping πŸ’–

  • Pod::Simple β€” event-based Pod-parsing framework
  • Pod::Simple::Methody β€” like Pod::Simple, but each sort of event calls its own method (like start_head3)
  • Pod::Simple::PullParser β€” a Pod-parsing framework like Pod::Simple, but with a token-stream interface
  • Pod::Simple::SimpleTree β€” a Pod-parsing framework like Pod::Simple, but with a tree interface
  • Pod::Simple::Checker β€” a simple Pod::Simple subclass that reads documents, and then makes a plaintext report of any errors found in the document
  • Pod::Simple::DumpAsXML β€” for dumping Pod documents as tidily indented XML, showing each event on its own line
  • Pod::Simple::XMLOutStream β€” dumps a Pod document as XML (without introducing extra whitespace as Pod::Simple::DumpAsXML does).
  • Pod::Simple::DumpAsText β€” for dumping Pod documents as tidily indented text, showing each event on its own line
  • Pod::Simple::LinkSection β€” class for objects representing the values of the TODO and TODO attributes of L<...> elements
  • Pod::Escapes β€” the module that Pod::Simple uses for evaluating E<...> content
  • Pod::Simple::Text β€” a simple plaintext formatter for Pod
  • Pod::Simple::TextContent β€” like Pod::Simple::Text, but makes no effort for indent or wrap the text being formatted
  • Pod::Simple::HTML β€” a simple HTML formatter for Pod
  • perlpod
  • perlpodspec
  • perldoc

🫢 SUPPORT 🫢

Questions or discussion about POD 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. that's literally it, bestie β€” empty email, no dramatic essay needed πŸ’Œ

This module is managed in an open GitHub repository, <https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or to clone <https://github.com/perl-pod/pod-simple.git> and send patches! collab era fr fr 🫢

Patches against Pod::Simple are welcome. Please send bug reports to <bug-pod-simple@rt.cpan.org>.


Copyright (c) 2002 Sean M. Burke.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

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. like, it's giving "use at your own vibe" β€” but those are the actual legal words, so keep them πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Pod::Simple was created by Sean M. Burke <sburke@cpan.org>. But don't bother him, he's retired. respect the legend's quiet era 🌸

Pod::Simple is maintained by:

  • Allison Randal allison@perl.org
  • Hans Dieter Pearcey hdp@cpan.org
  • David E. Wheeler dwheeler@cpan.org

and that's the whole page, bestie!! πŸŽ€ source/version: perl v5.42.3; date: 2026-11-03; page: Pod::Si...lassing(3pm) β€” periodt, go parse some Pod πŸ’–πŸ¦‹

πŸ“¦ where this page comes from