=head1 NAME
perlpodspec - Plain Old Documentation: format specification and notes
=head1 DESCRIPTION
This document is detailed notes on the Pod markup language. Most
people will only have to read L to know how to write
in Pod, but this document may answer some incidental questions to do
with parsing and rendering Pod.
In this document, "must" / "must not", "should" /
"should not", and "may" have their conventional (cf. RFC 2119)
meanings: "X must do Y" means that if X doesn't do Y, it's against
this specification, and should really be fixed. "X should do Y"
means that it's recommended, but X may fail to do Y, if there's a
good reason. "X may do Y" is merely a note that X can do Y at
will (although it is up to the reader to detect any connotation of
"and I think it would be I if X did Y" versus "it wouldn't
really I me if X did Y").
Notably, when I say "the parser should do Y", the
parser may fail to do Y, if the calling application explicitly
requests that the parser I do Y. I often phrase this as
"the parser should, by default, do Y." This doesn't I
the parser to provide an option for turning off whatever
feature Y is (like expanding tabs in verbatim paragraphs), although
it implicates that such an option I be provided.
=head1 Pod Definitions
Pod is embedded in files, typically Perl source files -- although you
can write a file that's nothing but Pod.
A B in a file consists of zero or more non-newline characters,
terminated by either a newline or the end of the file.
A B is usually a platform-dependent concept, but
Pod parsers should understand it to mean any of CR (ASCII 13), LF
(ASCII 10), or a CRLF (ASCII 13 followed immediately by ASCII 10), in
addition to any other system-specific meaning. The first CR/CRLF/LF
sequence in the file may be used as the basis for identifying the
newline sequence for parsing the rest of the file.
A B is a line consisting entirely of zero or more spaces
(ASCII 32) or tabs (ASCII 9), and terminated by a newline or end-of-file.
A B is a line containing one or more characters other
than space or tab (and terminated by a newline or end-of-file).
(I Many older Pod parsers did not accept a line consisting of
spaces/tabs and then a newline as a blank line -- the only lines they
considered blank were lines consisting of I,
terminated by a newline.)
B is used in this document as a blanket term for spaces,
tabs, and newline sequences. (By itself, this term usually refers
to literal whitespace. That is, sequences of whitespace characters
in Pod source, as opposed to "EE32>", which is a formatting
code that I a whitespace character.)
A B is a module meant for parsing Pod (regardless of
whether this involves calling callbacks or building a parse tree or
directly formatting it). A B (or B)
is a module or program that converts Pod to some other format (HTML,
plaintext, TeX, PostScript, RTF). A B might be a
formatter or translator, or might be a program that does something
else with the Pod (like counting words, scanning for index points,
etc.).
Pod content is contained in B. A Pod block starts with a
line that matches , and continues up to the next line
that matches C -- or up to the end of the file, if there is
no C line.
=for comment
The current perlsyn says:
[beginquote]
Note that pod translators should look at only paragraphs beginning
with a pod directive (it makes parsing easier), whereas the compiler
actually knows to look for pod escapes even in the middle of a
paragraph. This means that the following secret stuff will be ignored
by both the compiler and the translators.
$a=3;
=secret stuff
warn "Neither POD nor CODE!?"
=cut back
print "got $a\n";
You probably shouldn't rely upon the warn() being podded out forever.
Not all pod translators are well-behaved in this regard, and perhaps
the compiler will become pickier.
[endquote]
I think that those paragraphs should just be removed; paragraph-based
parsing seems to have been largely abandoned, because of the hassle
with non-empty blank lines messing up what people meant by "paragraph".
Even if the "it makes parsing easier" bit were especially true,
it wouldn't be worth the confusion of having perl and pod2whatever
actually disagree on what can constitute a Pod block.
Within a Pod block, there are B. A Pod paragraph
consists of non-blank lines of text, separated by one or more blank
lines.
For purposes of Pod processing, there are four types of paragraphs in
a Pod block:
=over
=item *
A command paragraph (also called a "directive"). The first line of
this paragraph must match C. Command paragraphs are
typically one line, as in:
=head1 NOTES
=item *
But they may span several (non-blank) lines:
=for comment
Hm, I wonder what it would look like if
you tried to write a BNF for Pod from this.
=head3 Dr. Strangelove, or: How I Learned to
Stop Worrying and Love the Bomb
I command paragraphs allow formatting codes in their content
(i.e., after the part that matches C), as in:
=head1 Did You Remember to C