Cari di Perl 
    Perl Tutorial
Daftar Isi
(Sebelumnya) POD plain old documentationPerl POD style guide (Berikutnya)
Language Reference

Plain Old Documentation: format specification and notes

Daftar Isi

NAME

perlpodspec - Plain Old Documentation: format specification and notes

DESCRIPTION

This document is detailed notes on the Pod markup language. Mostpeople will only have to read perlpod to know how to writein Pod, but this document may answer some incidental questions to dowith 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 againstthis 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 agood reason. "X may do Y" is merely a note that X can do Y atwill (although it is up to the reader to detect any connotation of"and I think it would be nice if X did Y" versus "it wouldn'treally bother me if X did Y").

Notably, when I say "the parser should do Y", theparser may fail to do Y, if the calling application explicitlyrequests that the parser not do Y. I often phrase this as"the parser should, by default, do Y." This doesn't requirethe parser to provide an option for turning off whateverfeature Y is (like expanding tabs in verbatim paragraphs), althoughit implicates that such an option may be provided.

Pod Definitions

Pod is embedded in files, typically Perl source files, although youcan write a file that's nothing but Pod.

A line in a file consists of zero or more non-newline characters,terminated by either a newline or the end of the file.

A newline sequence is usually a platform-dependent concept, butPod parsers should understand it to mean any of CR (ASCII 13), LF(ASCII 10), or a CRLF (ASCII 13 followed immediately by ASCII 10), inaddition to any other system-specific meaning. The first CR/CRLF/LFsequence in the file may be used as the basis for identifying thenewline sequence for parsing the rest of the file.

A blank line 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 non-blank line is a line containing one or more characters otherthan space or tab (and terminated by a newline or end-of-file).

(Note: Many older Pod parsers did not accept a line consisting ofspaces/tabs and then a newline as a blank line. The only lines theyconsidered blank were lines consisting of no characters at all,terminated by a newline.)

Whitespace is used in this document as a blanket term for spaces,tabs, and newline sequences. (By itself, this term usually refersto literal whitespace. That is, sequences of whitespace charactersin Pod source, as opposed to "E<32>", which is a formattingcode that denotes a whitespace character.)

A Pod parser is a module meant for parsing Pod (regardless ofwhether this involves calling callbacks or building a parse tree ordirectly formatting it). A Pod formatter (or Pod translator)is a module or program that converts Pod to some other format (HTML,plaintext, TeX, PostScript, RTF). A Pod processor might be aformatter or translator, or might be a program that does somethingelse with the Pod (like counting words, scanning for index points,etc.).

Pod content is contained in Pod blocks. A Pod block starts with aline that matches <m/\A=[a-zA-Z]/>, and continues up to the next linethat matches m/\A=cut/ or up to the end of the file if there isno m/\A=cut/ line.

Within a Pod block, there are Pod paragraphs. A Pod paragraphconsists of non-blank lines of text, separated by one or more blanklines.

For purposes of Pod processing, there are four types of paragraphs ina Pod block:

  • A command paragraph (also called a "directive"). The first line ofthis paragraph must match m/\A=[a-zA-Z]/. Command paragraphs aretypically one line, as in:

    1. =head1 NOTES
    2. =item *

    But they may span several (non-blank) lines:

    1. =for comment
    2. Hm, I wonder what it would look like if
    3. you tried to write a BNF for Pod from this.
    4. =head3 Dr. Strangelove, or: How I Learned to
    5. Stop Worrying and Love the Bomb

    Some command paragraphs allow formatting codes in their content(i.e., after the part that matches m/\A=[a-zA-Z]\S*\s*/), as in:

    1. =head1 Did You Remember to C<use strict;>?

    In other words, the Pod processing handler for "head1" will apply thesame processing to "Did You Remember to C<use strict;>?" that itwould to an ordinary paragraph (i.e., formatting codes like"C<...>") are parsed and presumably formatted appropriately, andwhitespace in the form of literal spaces and/or tabs is notsignificant.

  • A verbatim paragraph. The first line of this paragraph must be aliteral space or tab, and this paragraph must not be inside a "=beginidentifier", ... "=end identifier" sequence unless"identifier" begins with a colon (":"). That is, if a paragraphstarts with a literal space or tab, but is inside a"=begin identifier", ... "=end identifier" region, then it'sa data paragraph, unless "identifier" begins with a colon.

    Whitespace is significant in verbatim paragraphs (although, inprocessing, tabs are probably expanded).

  • An ordinary paragraph. A paragraph is an ordinary paragraphif its first line matches neither m/\A=[a-zA-Z]/ norm/\A[ \t]/, and if it's not inside a "=begin identifier",... "=end identifier" sequence unless "identifier" begins witha colon (":").

  • A data paragraph. This is a paragraph that is inside a "=beginidentifier" ... "=end identifier" sequence where"identifier" does not begin with a literal colon (":"). Insome sense, a data paragraph is not part of Pod at all (i.e.,effectively it's "out-of-band"), since it's not subject to most kindsof Pod parsing; but it is specified here, since Podparsers need to be able to call an event for it, or store it in someform in a parse tree, or at least just parse around it.

For example: consider the following paragraphs:

  1. # <- that's the 0th column
  2. =head1 Foo
  3. Stuff
  4. $foo->bar
  5. =cut

Here, "=head1 Foo" and "=cut" are command paragraphs because the firstline of each matches m/\A=[a-zA-Z]/. "[space][space]$foo->bar"is a verbatim paragraph, because its first line starts with a literalwhitespace character (and there's no "=begin"..."=end" region around).

The "=begin identifier" ... "=end identifier" commands stopparagraphs that they surround from being parsed as ordinary or verbatimparagraphs, if identifier doesn't begin with a colon. Thisis discussed in detail in the sectionAbout Data Paragraphs and =begin/=end Regions.

Pod Commands

This section is intended to supplement and clarify the discussion inCommand Paragraph in perlpod. These are the currently recognizedPod commands:

  • "=head1", "=head2", "=head3", "=head4"

    This command indicates that the text in the remainder of the paragraphis a heading. That text may contain formatting codes. Examples:

    1. =head1 Object Attributes
    2. =head3 What B<Not> to Do!
  • "=pod"

    This command indicates that this paragraph begins a Pod block. (If weare already in the middle of a Pod block, this command has no effect atall.) If there is any text in this command paragraph after "=pod",it must be ignored. Examples:

    1. =pod
    2. This is a plain Pod paragraph.
    3. =pod This text is ignored.
  • "=cut"

    This command indicates that this line is the end of this previouslystarted Pod block. If there is any text after "=cut" on the line, it must beignored. Examples:

    1. =cut
    2. =cut The documentation ends here.
    3. =cut
    4. # This is the first line of program text.
    5. sub foo { # This is the second.

    It is an error to try to start a Pod block with a "=cut" command. Inthat case, the Pod processor must halt parsing of the input file, andmust by default emit a warning.

  • "=over"

    This command indicates that this is the start of a list/indentregion. If there is any text following the "=over", it must consistof only a nonzero positive numeral. The semantics of this numeral isexplained in the About =over...=back Regions section, furtherbelow. Formatting codes are not expanded. Examples:

    1. =over 3
    2. =over 3.5
    3. =over
  • "=item"

    This command indicates that an item in a list begins here. Formattingcodes are processed. The semantics of the (optional) text in theremainder of this paragraph areexplained in the About =over...=back Regions section, furtherbelow. Examples:

    1. =item
    2. =item *
    3. =item *
    4. =item 14
    5. =item 3.
    6. =item C<< $thing->stuff(I<dodad>) >>
    7. =item For transporting us beyond seas to be tried for pretended
    8. offenses
    9. =item He is at this time transporting large armies of foreign
    10. mercenaries to complete the works of death, desolation and
    11. tyranny, already begun with circumstances of cruelty and perfidy
    12. scarcely paralleled in the most barbarous ages, and totally
    13. unworthy the head of a civilized nation.
  • "=back"

    This command indicates that this is the end of the region begunby the most recent "=over" command. It permits no text after the"=back" command.

  • "=begin formatname"
  • "=begin formatname parameter"

    This marks the following paragraphs (until the matching "=endformatname") as being for some special kind of processing. Unless"formatname" begins with a colon, the contained non-commandparagraphs are data paragraphs. But if "formatname" does beginwith a colon, then non-command paragraphs are ordinary paragraphsor data paragraphs. This is discussed in detail in the sectionAbout Data Paragraphs and =begin/=end Regions.

    It is advised that formatnames match the regexpm/\A:?[-a-zA-Z0-9_]+\z/. Everything following whitespace after theformatname is a parameter that may be used by the formatter when dealingwith this region. This parameter must not be repeated in the "=end"paragraph. Implementors should anticipate future expansion in thesemantics and syntax of the first parameter to "=begin"/"=end"/"=for".

  • "=end formatname"

    This marks the end of the region opened by the matching"=begin formatname" region. If "formatname" is not the formatnameof the most recent open "=begin formatname" region, then thisis an error, and must generate an error message. Thisis discussed in detail in the sectionAbout Data Paragraphs and =begin/=end Regions.

  • "=for formatname text..."

    This is synonymous with:

    1. =begin formatname
    2. text...
    3. =end formatname

    That is, it creates a region consisting of a single paragraph; thatparagraph is to be treated as a normal paragraph if "formatname"begins with a ":"; if "formatname" doesn't begin with a colon,then "text..." will constitute a data paragraph. There is no wayto use "=for formatname text..." to express "text..." as a verbatimparagraph.

  • "=encoding encodingname"

    This command, which should occur early in the document (at leastbefore any non-US-ASCII data!), declares that this document isencoded in the encoding encodingname, which must bean encoding name that Encode recognizes. (Encode's listof supported encodings, in Encode::Supported, is useful here.)If the Pod parser cannot decode the declared encoding, it should emit a warning and may abort parsing the documentaltogether.

    A document having more than one "=encoding" line should beconsidered an error. Pod processors may silently tolerate this ifthe not-first "=encoding" lines are just duplicates of thefirst one (e.g., if there's a "=encoding utf8" line, and later onanother "=encoding utf8" line). But Pod processors should complain ifthere are contradictory "=encoding" lines in the same document(e.g., if there is a "=encoding utf8" early in the document and"=encoding big5" later). Pod processors that recognize BOMsmay also complain if they see an "=encoding" linethat contradicts the BOM (e.g., if a document with a UTF-16LEBOM has an "=encoding shiftjis" line).

If a Pod processor sees any command other than the ones listedabove (like "=head", or "=haed1", or "=stuff", or "=cuttlefish",or "=w123"), that processor must by default treat this as anerror. It must not process the paragraph beginning with thatcommand, must by default warn of this as an error, and mayabort the parse. A Pod parser may allow a way for particularapplications to add to the above list of known commands, and tostipulate, for each additional command, whether formattingcodes should be processed.

Future versions of this specification may add additionalcommands.

Pod Formatting Codes

(Note that in previous drafts of this document and of perlpod,formatting codes were referred to as "interior sequences", andthis term may still be found in the documentation for Pod parsers,and in error messages from Pod processors.)

There are two syntaxes for formatting codes:

  • A formatting code starts with a capital letter (just US-ASCII [A-Z])followed by a "<", any number of characters, and ending with the firstmatching ">". Examples:

    1. That's what I<you> think!
    2. What's C<dump()> for?
    3. X<C<chmod> and C<unlink()> Under Different Operating Systems>
  • A formatting code starts with a capital letter (just US-ASCII [A-Z])followed by two or more "<"'s, one or more whitespace characters,any number of characters, one or more whitespace characters,and ending with the first matching sequence of two or more ">"'s, wherethe number of ">"'s equals the number of "<"'s in the opening of thisformatting code. Examples:

    1. That's what I<< you >> think!
    2. C<<< open(X, ">>thing.dat") || die $! >>>
    3. B<< $foo->bar(); >>

    With this syntax, the whitespace character(s) after the "C<<<"and before the ">>" (or whatever letter) are not renderable. Theydo not signify whitespace, are merely part of the formatting codesthemselves. That is, these are all synonymous:

    1. C<thing>
    2. C<< thing >>
    3. C<< thing >>
    4. C<<< thing >>>
    5. C<<<<
    6. thing
    7. >>>>

    and so on.

    Finally, the multiple-angle-bracket form does not alter the interpretationof nested formatting codes, meaning that the following four example lines areidentical in meaning:

    1. B<example: C<$a E<lt>=E<gt> $b>>
    2. B<example: C<< $a <=> $b >>>
    3. B<example: C<< $a E<lt>=E<gt> $b >>>
    4. B<<< example: C<< $a E<lt>=E<gt> $b >> >>>

In parsing Pod, a notably tricky part is the correct parsing of(potentially nested!) formatting codes. Implementors shouldconsult the code in the parse_text routine in Pod::Parser as anexample of a correct implementation.

  • I<text> -- italic text

    See the brief discussion in Formatting Codes in perlpod.

  • B<text> -- bold text

    See the brief discussion in Formatting Codes in perlpod.

  • C<code> -- code text

    See the brief discussion in Formatting Codes in perlpod.

  • F<filename> -- style for filenames

    See the brief discussion in Formatting Codes in perlpod.

  • X<topic name> -- an index entry

    See the brief discussion in Formatting Codes in perlpod.

    This code is unusual in that most formatters completely discardthis code and its content. Other formatters will render it withinvisible codes that can be used in building an index ofthe current document.

  • Z<> -- a null (zero-effect) formatting code

    Discussed briefly in Formatting Codes in perlpod.

    This code is unusual is that it should have no content. That is,a processor may complain if it sees Z<potatoes>. Whetheror not it complains, the potatoes text should ignored.

  • L<name> -- a hyperlink

    The complicated syntaxes of this code are discussed at length inFormatting Codes in perlpod, and implementation details arediscussed below, in About L<...> Codes. Parsing thecontents of L<content> is tricky. Notably, the content has to bechecked for whether it looks like a URL, or whether it has to be spliton literal "|" and/or "/" (in the right order!), and so on,before E<...> codes are resolved.

  • E<escape> -- a character escape

    See Formatting Codes in perlpod, and several points inNotes on Implementing Pod Processors.

  • S<text> -- text contains non-breaking spaces

    This formatting code is syntactically simple, but semanticallycomplex. What it means is that each space in the printablecontent of this code signifies a non-breaking space.

    Consider:

    1. C<$x ? $y : $z>
    2. S<C<$x ? $y : $z>>

    Both signify the monospace (c[ode] style) text consisting of"$x", one space, "?", one space, ":", one space, "$z". Thedifference is that in the latter, with the S code, those spacesare not "normal" spaces, but instead are non-breaking spaces.

If a Pod processor sees any formatting code other than the oneslisted above (as in "N<...>", or "Q<...>", etc.), thatprocessor must by default treat this as an error.A Pod parser may allow a way for particularapplications to add to the above list of known formatting codes;a Pod parser might even allow a way to stipulate, for each additionalcommand, whether it requires some form of special processing, asL<...> does.

Future versions of this specification may add additionalformatting codes.

Historical note: A few older Pod processors would not see a ">" asclosing a "C<" code, if the ">" was immediately preceded bya "-". This was so that this:

  1. C<$foo->bar>

would parse as equivalent to this:

  1. C<$foo-E<gt>bar>

instead of as equivalent to a "C" formatting code containing only "$foo-", and then a "bar>" outside the "C" formatting code. Thisproblem has since been solved by the addition of syntaxes like this:

  1. C<< $foo->bar >>

Compliant parsers must not treat "->" as special.

Formatting codes absolutely cannot span paragraphs. If a code isopened in one paragraph, and no closing code is found by the end ofthat paragraph, the Pod parser must close that formatting code,and should complain (as in "Unterminated I code in the paragraphstarting at line 123: 'Time objects are not...'"). So thesetwo paragraphs:

  1. I<I told you not to do this!
  2. Don't make me say it again!>

...must not be parsed as two paragraphs in italics (with the Icode starting in one paragraph and starting in another.) Instead,the first paragraph should generate a warning, but that aside, theabove code must parse as if it were:

  1. I<I told you not to do this!>
  2. Don't make me say it again!E<gt>

(In SGMLish jargon, all Pod commands are like block-levelelements, whereas all Pod formatting codes are like inline-levelelements.)

Notes on Implementing Pod Processors

The following is a long section of miscellaneous requirementsand suggestions to do with Pod processing.

  • Pod formatters should tolerate lines in verbatim blocks that are ofany length, even if that means having to break them (possibly severaltimes, for very long lines) to avoid text running off the side of thepage. Pod formatters may warn of such line-breaking. Such warningsare particularly appropriate for lines are over 100 characters long, whichare usually not intentional.

  • Pod parsers must recognize all of the three well-known newlineformats: CR, LF, and CRLF. See perlport.

  • Pod parsers should accept input lines that are of any length.

  • Since Perl recognizes a Unicode Byte Order Mark at the start of filesas signaling that the file is Unicode encoded as in UTF-16 (whetherbig-endian or little-endian) or UTF-8, Pod parsers should do thesame. Otherwise, the character encoding should be understood asbeing UTF-8 if the first highbit byte sequence in the file seemsvalid as a UTF-8 sequence, or otherwise as Latin-1.

    Future versions of this specification may specifyhow Pod can accept other encodings. Presumably treatment of otherencodings in Pod parsing would be as in XML parsing: whatever theencoding declared by a particular Pod file, content is to bestored in memory as Unicode characters.

  • The well known Unicode Byte Order Marks are as follows: if thefile begins with the two literal byte values 0xFE 0xFF, this isthe BOM for big-endian UTF-16. If the file begins with the twoliteral byte value 0xFF 0xFE, this is the BOM for little-endianUTF-16. If the file begins with the three literal byte values0xEF 0xBB 0xBF, this is the BOM for UTF-8.

  • A naive but sufficient heuristic for testing the first highbitbyte-sequence in a BOM-less file (whether in code or in Pod!), to seewhether that sequence is valid as UTF-8 (RFC 2279) is to check whetherthat the first byte in the sequence is in the range 0xC0 - 0xFDand whether the next byte is in the range0x80 - 0xBF. If so, the parser may conclude that this file is inUTF-8, and all highbit sequences in the file should be assumed tobe UTF-8. Otherwise the parser should treat the file as beingin Latin-1. In the unlikely circumstance that the first highbitsequence in a truly non-UTF-8 file happens to appear to be UTF-8, onecan cater to our heuristic (as well as any more intelligent heuristic)by prefacing that line with a comment line containing a highbitsequence that is clearly not valid as UTF-8. A line consistingof simply "#", an e-acute, and any non-highbit byte,is sufficient to establish this file's encoding.

  • This document's requirements and suggestions about encodingsdo not apply to Pod processors running on non-ASCII platforms,notably EBCDIC platforms.

  • Pod processors must treat a "=for [label] [content...]" paragraph asmeaning the same thing as a "=begin [label]" paragraph, content, andan "=end [label]" paragraph. (The parser may conflate these twoconstructs, or may leave them distinct, in the expectation that theformatter will nevertheless treat them the same.)

  • When rendering Pod to a format that allows comments (i.e., to nearlyany format other than plaintext), a Pod formatter must insert commenttext identifying its name and version number, and the name andversion numbers of any modules it might be using to process the Pod.Minimal examples:

    1. %% POD::Pod2PS v3.14159, using POD::Parser v1.92
    2. <!-- Pod::HTML v3.14159, using POD::Parser v1.92 -->
    3. {\doccomm generated by Pod::Tree::RTF 3.14159 using Pod::Tree 1.08}
    4. .\" Pod::Man version 3.14159, using POD::Parser version 1.92

    Formatters may also insert additional comments, including: therelease date of the Pod formatter program, the contact address forthe author(s) of the formatter, the current time, the name of inputfile, the formatting options in effect, version of Perl used, etc.

    Formatters may also choose to note errors/warnings as comments,besides or instead of emitting them otherwise (as in messages toSTDERR, or dieing).

  • Pod parsers may emit warnings or error messages ("Unknown E codeE<zslig>!") to STDERR (whether through printing to STDERR, orwarning/carping, or dieing/croaking), but must allowsuppressing all such STDERR output, and instead allow an option forreporting errors/warningsin some other way, whether by triggering a callback, or noting errorsin some attribute of the document object, or some similarly unobtrusivemechanism -- or even by appending a "Pod Errors" section to the end ofthe parsed form of the document.

  • In cases of exceptionally aberrant documents, Pod parsers may abort theparse. Even then, using dieing/croaking is to be avoided; wherepossible, the parser library may simply close the input fileand add text like "*** Formatting Aborted ***" to the end of the(partial) in-memory document.

  • In paragraphs where formatting codes (like E<...>, B<...>)are understood (i.e., not verbatim paragraphs, but includingordinary paragraphs, and command paragraphs that produce renderabletext, like "=head1"), literal whitespace should generally be considered"insignificant", in that one literal space has the same meaning as any(nonzero) number of literal spaces, literal newlines, and literal tabs(as long as this produces no blank lines, since those would terminatethe paragraph). Pod parsers should compact literal whitespace in eachprocessed paragraph, but may provide an option for overriding this(since some processing tasks do not require it), or may followadditional special rules (for example, specially treatingperiod-space-space or period-newline sequences).

  • Pod parsers should not, by default, try to coerce apostrophe (') andquote (") into smart quotes (little 9's, 66's, 99's, etc), nor try toturn backtick (`) into anything else but a single backtick character(distinct from an open quote character!), nor "--" into anything buttwo minus signs. They must never do any of those things to textin C<...> formatting codes, and never ever to text in verbatimparagraphs.

  • When rendering Pod to a format that has two kinds of hyphens (-), onethat's a non-breaking hyphen, and another that's a breakable hyphen(as in "object-oriented", which can be split across lines as"object-", newline, "oriented"), formatters are encouraged togenerally translate "-" to non-breaking hyphen, but may applyheuristics to convert some of these to breaking hyphens.

  • Pod formatters should make reasonable efforts to keep words of Perlcode from being broken across lines. For example, "Foo::Bar" in someformatting systems is seen as eligible for being broken across linesas "Foo::" newline "Bar" or even "Foo::-" newline "Bar". This shouldbe avoided where possible, either by disabling all line-breaking inmid-word, or by wrapping particular words with internal punctuationin "don't break this across lines" codes (which in some formats maynot be a single code, but might be a matter of inserting non-breakingzero-width spaces between every pair of characters in a word.)

  • Pod parsers should, by default, expand tabs in verbatim paragraphs asthey are processed, before passing them to the formatter or otherprocessor. Parsers may also allow an option for overriding this.

  • Pod parsers should, by default, remove newlines from the end ofordinary and verbatim paragraphs before passing them to theformatter. For example, while the paragraph you're reading nowcould be considered, in Pod source, to end with (and contain)the newline(s) that end it, it should be processed as ending with(and containing) the period character that ends this sentence.

  • Pod parsers, when reporting errors, should make some effort to reportan approximate line number ("Nested E<>'s in Paragraph #52, nearline 633 of Thing/Foo.pm!"), instead of merely noting the paragraphnumber ("Nested E<>'s in Paragraph #52 of Thing/Foo.pm!"). Wherethis is problematic, the paragraph number should at least beaccompanied by an excerpt from the paragraph ("Nested E<>'s inParagraph #52 of Thing/Foo.pm, which begins 'Read/write accessor forthe C<interest rate> attribute...'").

  • Pod parsers, when processing a series of verbatim paragraphs oneafter another, should consider them to be one large verbatimparagraph that happens to contain blank lines. I.e., these twolines, which have a blank line between them:

    1. use Foo;
    2. print Foo->VERSION

    should be unified into one paragraph ("\tuse Foo;\n\n\tprintFoo->VERSION") before being passed to the formatter or otherprocessor. Parsers may also allow an option for overriding this.

    While this might be too cumbersome to implement in event-based Podparsers, it is straightforward for parsers that return parse trees.

  • Pod formatters, where feasible, are advised to avoid splitting shortverbatim paragraphs (under twelve lines, say) across pages.

  • Pod parsers must treat a line with only spaces and/or tabs on it as a"blank line" such as separates paragraphs. (Some older parsersrecognized only two adjacent newlines as a "blank line" but would notrecognize a newline, a space, and a newline, as a blank line. Thisis noncompliant behavior.)

  • Authors of Pod formatters/processors should make every effort toavoid writing their own Pod parser. There are already several inCPAN, with a wide range of interface styles -- and one of them,Pod::Parser, comes with modern versions of Perl.

  • Characters in Pod documents may be conveyed either as literals, or bynumber in E<n> codes, or by an equivalent mnemonic, as inE<eacute> which is exactly equivalent to E<233>.

    Characters in the range 32-126 refer to those well known US-ASCIIcharacters (also defined there by Unicode, with the same meaning),which all Pod formatters must render faithfully. Charactersin the ranges 0-31 and 127-159 should not be used (neither asliterals, nor as E<number> codes), except for theliteral byte-sequences for newline (13, 13 10, or 10), and tab (9).

    Characters in the range 160-255 refer to Latin-1 characters (alsodefined there by Unicode, with the same meaning). Characters above255 should be understood to refer to Unicode characters.

  • Be warnedthat some formatters cannot reliably render characters outside 32-126;and many are able to handle 32-126 and 160-255, but nothing above255.

  • Besides the well-known "E<lt>" and "E<gt>" codes forless-than and greater-than, Pod parsers must understand "E<sol>"for "/" (solidus, slash), and "E<verbar>" for "|" (vertical bar,pipe). Pod parsers should also understand "E<lchevron>" and"E<rchevron>" as legacy codes for characters 171 and 187, i.e.,"left-pointing double angle quotation mark" = "left pointingguillemet" and "right-pointing double angle quotation mark" = "rightpointing guillemet". (These look like little "<<" and ">>", and theyare now preferably expressed with the HTML/XHTML codes "E<laquo>"and "E<raquo>".)

  • Pod parsers should understand all "E<html>" codes as definedin the entity declarations in the most recent XHTML specification atwww.W3.org. Pod parsers must understand at least the entitiesthat define characters in the range 160-255 (Latin-1). Pod parsers,when faced with some unknown "E<identifier>" code,shouldn't simply replace it with nullstring (by default, at least),but may pass it through as a string consisting of the literal charactersE, less-than, identifier, greater-than. Or Pod parsers may offer thealternative option of processing such unknown"E<identifier>" codes by firing an event especiallyfor such codes, or by adding a special node-type to the in-memorydocument tree. Such "E<identifier>" may have special meaningto some processors, or some processors may choose to add them toa special error report.

  • Pod parsers must also support the XHTML codes "E<quot>" forcharacter 34 (doublequote, "), "E<amp>" for character 38(ampersand, &), and "E<apos>" for character 39 (apostrophe, ').

  • Note that in all cases of "E<whatever>", whatever (whetheran htmlname, or a number in any base) must consist only ofalphanumeric characters -- that is, whatever must watchm/\A\w+\z/. So "E< 0 1 2 3 >" is invalid, becauseit contains spaces, which aren't alphanumeric characters. Thispresumably does not need special treatment by a Pod processor;" 0 1 2 3 " doesn't look like a number in any base, so it wouldpresumably be looked up in the table of HTML-like names. Sincethere isn't (and cannot be) an HTML-like entity called " 0 1 2 3 ",this will be treated as an error. However, Pod processors maytreat "E< 0 1 2 3 >" or "E<e-acute>" as syntacticallyinvalid, potentially earning a different error message than theerror message (or warning, or event) generated by a merely unknown(but theoretically valid) htmlname, as in "E<qacute>"[sic]. However, Pod parsers are not required to make thisdistinction.

  • Note that E<number> must not be interpreted as simply"codepoint number in the current/native character set". It alwaysmeans only "the character represented by codepoint number inUnicode." (This is identical to the semantics of &#number; in XML.)

    This will likely require many formatters to have tables mapping fromtreatable Unicode codepoints (such as the "\xE9" for the e-acutecharacter) to the escape sequences or codes necessary for conveyingsuch sequences in the target output format. A converter to *roffwould, for example know that "\xE9" (whether conveyed literally, or viaa E<...> sequence) is to be conveyed as "e\*'".Similarly, a program rendering Pod in a Mac OS application window, wouldpresumably need to know that "\xE9" maps to codepoint 142 in MacRomanencoding that (at time of writing) is native for Mac OS. SuchUnicode2whatever mappings are presumably already widely available forcommon output formats. (Such mappings may be incomplete! Implementersare not expected to bend over backwards in an attempt to renderCherokee syllabics, Etruscan runes, Byzantine musical symbols, or anyof the other weird things that Unicode can encode.) Andif a Pod document uses a character not found in such a mapping, theformatter should consider it an unrenderable character.

  • If, surprisingly, the implementor of a Pod formatter can't find asatisfactory pre-existing table mapping from Unicode characters toescapes in the target format (e.g., a decent table of Unicodecharacters to *roff escapes), it will be necessary to build such atable. If you are in this circumstance, you should begin with thecharacters in the range 0x00A0 - 0x00FF, which is mostly the heavilyused accented characters. Then proceed (as patience permits andfastidiousness compels) through the characters that the (X)HTMLstandards groups judged important enough to merit mnemonicsfor. These are declared in the (X)HTML specifications at thewww.W3.org site. At time of writing (September 2001), the most recententity declaration files are:

    1. http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
    2. http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
    3. http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent

    Then you can progress through any remaining notable Unicode charactersin the range 0x2000-0x204D (consult the character tables atwww.unicode.org), and whatever else strikes your fancy. For example,in xhtml-symbol.ent, there is the entry:

    1. <!ENTITY infin "&#8734;"> <!-- infinity, U+221E ISOtech -->

    While the mapping "infin" to the character "\x{221E}" will (hopefully)have been already handled by the Pod parser, the presence of thecharacter in this file means that it's reasonably important enough toinclude in a formatter's table that maps from notable Unicode charactersto the codes necessary for rendering them. So for a Unicode-to-*roffmapping, for example, this would merit the entry:

    1. "\x{221E}" => '\(in',

    It is eagerly hoped that in the future, increasing numbers of formats(and formatters) will support Unicode characters directly (as (X)HTMLdoes with &infin;, &#8734;, or &#x221E;), reducing the needfor idiosyncratic mappings of Unicode-to-my_escapes.

  • It is up to individual Pod formatter to display good judgement whenconfronted with an unrenderable character (which is distinct from anunknown E<thing> sequence that the parser couldn't resolve toanything, renderable or not). It is good practice to map Latin letterswith diacritics (like "E<eacute>"/"E<233>") to the correspondingunaccented US-ASCII letters (like a simple character 101, "e"), butclearly this is often not feasible, and an unrenderable character maybe represented as "?", or the like. In attempting a sane fallback(as from E<233> to "e"), Pod formatters may use the%Latin1Code_to_fallback table in Pod::Escapes, orText::Unidecode, if available.

    For example, this Pod text:

    1. magic is enabled if you set C<$Currency> to 'E<euro>'.

    may be rendered as:"magic is enabled if you set $Currency to '?'" or as"magic is enabled if you set $Currency to '[euro]'", or as"magic is enabled if you set $Currency to '[x20AC]', etc.

    A Pod formatter may also note, in a comment or warning, a list of whatunrenderable characters were encountered.

  • E<...> may freely appear in any formatting code (other thanin another E<...> or in an Z<>). That is, "X<TheE<euro>1,000,000 Solution>" is valid, as is "L<TheE<euro>1,000,000 Solution|Million::Euros>".

  • Some Pod formatters output to formats that implement non-breakingspaces as an individual character (which I'll call "NBSP"), andothers output to formats that implement non-breaking spaces just asspaces wrapped in a "don't break this across lines" code. Note thatat the level of Pod, both sorts of codes can occur: Pod can contain aNBSP character (whether as a literal, or as a "E<160>" or"E<nbsp>" code); and Pod can contain "S<fooI<bar> baz>" codes, where "mere spaces" (character 32) insuch codes are taken to represent non-breaking spaces. Podparsers should consider supporting the optional parsing of "S<fooI<bar> baz>" as if it were"fooNBSPI<bar>NBSPbaz", and, going the other way, theoptional parsing of groups of words joined by NBSP's as if each groupwere in a S<...> code, so that formatters may use therepresentation that maps best to what the output format demands.

  • Some processors may find that the S<...> code is easiest toimplement by replacing each space in the parse tree under the contentof the S, with an NBSP. But note: the replacement should apply not tospaces in all text, but only to spaces in printable text. (Thisdistinction may or may not be evident in the particular tree/eventmodel implemented by the Pod parser.) For example, consider thisunusual case:

    1. S<L</Autoloaded Functions>>

    This means that the space in the middle of the visible link text mustnot be broken across lines. In other words, it's the same as this:

    1. L<"AutoloadedE<160>Functions"/Autoloaded Functions>

    However, a misapplied space-to-NBSP replacement could (wrongly)produce something equivalent to this:

    1. L<"AutoloadedE<160>Functions"/AutoloadedE<160>Functions>

    ...which is almost definitely not going to work as a hyperlink (assumingthis formatter outputs a format supporting hypertext).

    Formatters may choose to just not support the S format code,especially in cases where the output format simply has no NBSPcharacter/code and no code for "don't break this stuff across lines".

  • Besides the NBSP character discussed above, implementors are remindedof the existence of the other "special" character in Latin-1, the"soft hyphen" character, also known as "discretionary hyphen",i.e. E<173> = E<0xAD> =E<shy>). This character expresses an optional hyphenationpoint. That is, it normally renders as nothing, but may render as a"-" if a formatter breaks the word at that point. Pod formattersshould, as appropriate, do one of the following: 1) render this witha code with the same meaning (e.g., "\-" in RTF), 2) pass it throughin the expectation that the formatter understands this character assuch, or 3) delete it.

    For example:

    1. sigE<shy>action
    2. manuE<shy>script
    3. JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi

    These signal to a formatter that if it is to hyphenate "sigaction"or "manuscript", then it should be done as"sig-[linebreak]action" or "manu-[linebreak]script"(and if it doesn't hyphenate it, then the E<shy> doesn'tshow up at all). And if it isto hyphenate "Jarkko" and/or "Hietaniemi", it can doso only at the points where there is a E<shy> code.

    In practice, it is anticipated that this character will not be usedoften, but formatters should either support it, or delete it.

  • If you think that you want to add a new command to Pod (like, say, a"=biblio" command), consider whether you could get the sameeffect with a for or begin/end sequence: "=for biblio ..." or "=beginbiblio" ... "=end biblio". Pod processors that don't understand"=for biblio", etc, will simply ignore it, whereas they may complainloudly if they see "=biblio".

  • Throughout this document, "Pod" has been the preferred spelling forthe name of the documentation format. One may also use "POD" or"pod". For the documentation that is (typically) in the Podformat, you may use "pod", or "Pod", or "POD". Understanding thesedistinctions is useful; but obsessing over how to spell them, usuallyis not.

About L<...> Codes

As you can tell from a glance at perlpod, the L<...>code is the most complex of the Pod formatting codes. The points belowwill hopefully clarify what it means and how processors should dealwith it.

  • In parsing an L<...> code, Pod parsers must distinguish at leastfour attributes:

    • First:

      The link-text. If there is none, this must be undef. (E.g., in"L<Perl Functions|perlfunc>", the link-text is "Perl Functions".In "L<Time::HiRes>" and even "L<|Time::HiRes>", there is nolink text. Note that link text may contain formatting.)

    • Second:

      The possibly inferred link-text; i.e., if there was no real linktext, then this is the text that we'll infer in its place. (E.g., for"L<Getopt::Std>", the inferred link text is "Getopt::Std".)

    • Third:

      The name or URL, or undef if none. (E.g., in "L<PerlFunctions|perlfunc>", the name (also sometimes called the page)is "perlfunc". In "L</CAVEATS>", the name is undef.)

    • Fourth:

      The section (AKA "item" in older perlpods), or undef if none. E.g.,in "L<Getopt::Std/DESCRIPTION>", "DESCRIPTION" is the section. (Notethat this is not the same as a manpage section like the "5" in "man 5crontab". "Section Foo" in the Pod sense means the part of the textthat's introduced by the heading or item whose text is "Foo".)

    Pod parsers may also note additional attributes including:

    • Fifth:

      A flag for whether item 3 (if present) is a URL (like"http://lists.perl.org" is), in which case there should be no sectionattribute; a Pod name (like "perldoc" and "Getopt::Std" are); orpossibly a man page name (like "crontab(5)" is).

    • Sixth:

      The raw original L<...> content, before text is split on"|", "/", etc, and before E<...> codes are expanded.

    (The above were numbered only for concise reference below. It is nota requirement that these be passed as an actual list or array.)

    For example:

    1. L<Foo::Bar>
    2. => undef, # link text
    3. "Foo::Bar", # possibly inferred link text
    4. "Foo::Bar", # name
    5. undef, # section
    6. 'pod', # what sort of link
    7. "Foo::Bar" # original content
    8. L<Perlport's section on NL's|perlport/Newlines>
    9. => "Perlport's section on NL's", # link text
    10. "Perlport's section on NL's", # possibly inferred link text
    11. "perlport", # name
    12. "Newlines", # section
    13. 'pod', # what sort of link
    14. "Perlport's section on NL's|perlport/Newlines" # orig. content
    15. L<perlport/Newlines>
    16. => undef, # link text
    17. '"Newlines" in perlport', # possibly inferred link text
    18. "perlport", # name
    19. "Newlines", # section
    20. 'pod', # what sort of link
    21. "perlport/Newlines" # original content
    22. L<crontab(5)/"DESCRIPTION">
    23. => undef, # link text
    24. '"DESCRIPTION" in crontab(5)', # possibly inferred link text
    25. "crontab(5)", # name
    26. "DESCRIPTION", # section
    27. 'man', # what sort of link
    28. 'crontab(5)/"DESCRIPTION"' # original content
    29. L</Object Attributes>
    30. => undef, # link text
    31. '"Object Attributes"', # possibly inferred link text
    32. undef, # name
    33. "Object Attributes", # section
    34. 'pod', # what sort of link
    35. "/Object Attributes" # original content
    36. L<http://www.perl.org/>
    37. => undef, # link text
    38. "http://www.perl.org/", # possibly inferred link text
    39. "http://www.perl.org/", # name
    40. undef, # section
    41. 'url', # what sort of link
    42. "http://www.perl.org/" # original content
    43. L<Perl.org|http://www.perl.org/>
    44. => "Perl.org", # link text
    45. "http://www.perl.org/", # possibly inferred link text
    46. "http://www.perl.org/", # name
    47. undef, # section
    48. 'url', # what sort of link
    49. "Perl.org|http://www.perl.org/" # original content

    Note that you can distinguish URL-links from anything else by thefact that they match m/\A\w+:[^:\s]\S*\z/. SoL<http://www.perl.com> is a URL, butL<HTTP::Response> isn't.

  • In case of L<...> codes with no "text|" part in them,older formatters have exhibited great variation in actually displayingthe link or cross reference. For example, L<crontab(5)> would renderas "the crontab(5) manpage", or "in the crontab(5) manpage"or just "crontab(5)".

    Pod processors must now treat "text|"-less links as follows:

    1. L<name> => L<name|name>
    2. L</section> => L<"section"|/section>
    3. L<name/section> => L<"section" in name|name/section>
  • Note that section names might contain markup. I.e., if a sectionstarts with:

    1. =head2 About the C<-M> Operator

    or with:

    1. =item About the C<-M> Operator

    then a link to it would look like this:

    1. L<somedoc/About the C<-M> Operator>

    Formatters may choose to ignore the markup for purposes of resolvingthe link and use only the renderable characters in the section name,as in:

    1. <h1><a name="About_the_-M_Operator">About the <code>-M</code>
    2. Operator</h1>
    3. ...
    4. <a href="somedoc#About_the_-M_Operator">About the <code>-M</code>
    5. Operator" in somedoc</a>
  • Previous versions of perlpod distinguished L<name/"section">links from L<name/item> links (and their targets). Thesehave been merged syntactically and semantically in the currentspecification, and section can refer either to a "=headn HeadingContent" command or to a "=item Item Content" command. Thisspecification does not specify what behavior should be in the caseof a given document having several things all seeming to produce thesame section identifier (e.g., in HTML, several things all producingthe same anchorname in <a name="anchorname">...</a>elements). Where Pod processors can control this behavior, they shoulduse the first such anchor. That is, L<Foo/Bar> refers to thefirst "Bar" section in Foo.

    But for some processors/formats this cannot be easily controlled; aswith the HTML example, the behavior of multiple ambiguous<a name="anchorname">...</a> is most easily just left up tobrowsers to decide.

  • In a L<text|...> code, text may contain formatting codesfor formatting or for E<...> escapes, as in:

    1. L<B<ummE<234>stuff>|...>

    For L<...> codes without a "name|" part, onlyE<...> and Z<> codes may occur. That is,authors should not use "L<B<Foo::Bar>>".

    Note, however, that formatting codes and Z<>'s can occur in anyand all parts of an L<...> (i.e., in name, section, text,and url).

    Authors must not nest L<...> codes. For example, "L<TheL<Foo::Bar> man page>" should be treated as an error.

  • Note that Pod authors may use formatting codes inside the "text"part of "L<text|name>" (and so on for L<text|/"sec">).

    In other words, this is valid:

    1. Go read L<the docs on C<$.>|perlvar/"$.">

    Some output formats that do allow rendering "L<...>" codes ashypertext, might not allow the link-text to be formatted; inthat case, formatters will have to just ignore that formatting.

  • At time of writing, L<name> values are of two types:either the name of a Pod page like L<Foo::Bar> (whichmight be a real Perl module or program in an @INC / PATHdirectory, or a .pod file in those places); or the name of a Unixman page, like L<crontab(5)>. In theory, L<chmod>in ambiguous between a Pod page called "chmod", or the Unix man page"chmod" (in whatever man-section). However, the presence of a stringin parens, as in "crontab(5)", is sufficient to signal that whatis being discussed is not a Pod page, and so is presumably aUnix man page. The distinction is of no importance to manyPod processors, but some processors that render to hypertext formatsmay need to distinguish them in order to know how to render agiven L<foo> code.

  • Previous versions of perlpod allowed for a L<section> syntax (as inL<Object Attributes>), which was not easily distinguishable fromL<name> syntax and for L<"section"> which was onlyslightly less ambiguous. This syntax is no longer in the specification, andhas been replaced by the L</section> syntax (where the slash wasformerly optional). Pod parsers should tolerate the L<"section">syntax, for a while at least. The suggested heuristic for distinguishingL<section> from L<name> is that if it contains anywhitespace, it's a section. Pod processors should warn about this beingdeprecated syntax.

About =over...=back Regions

"=over"..."=back" regions are used for various kinds of list-likestructures. (I use the term "region" here simply as a collectiveterm for everything from the "=over" to the matching "=back".)

  • The non-zero numeric indentlevel in "=over indentlevel" ..."=back" is used for giving the formatter a clue as to how many"spaces" (ems, or roughly equivalent units) it should tab over,although many formatters will have to convert this to an absolutemeasurement that may not exactly match with the size of spaces (or M's)in the document's base font. Other formatters may have to completelyignore the number. The lack of any explicit indentlevel parameter isequivalent to an indentlevel value of 4. Pod processors maycomplain if indentlevel is present but is not a positive numbermatching m/\A(\d*\.)?\d+\z/.

  • Authors of Pod formatters are reminded that "=over" ... "=back" maymap to several different constructs in your output format. Forexample, in converting Pod to (X)HTML, it can map to any of<ul>...</ul>, <ol>...</ol>, <dl>...</dl>, or<blockquote>...</blockquote>. Similarly, "=item" can map to <li> or<dt>.

  • Each "=over" ... "=back" region should be one of the following:

    • An "=over" ... "=back" region containing only "=item *" commands,each followed by some number of ordinary/verbatim paragraphs, othernested "=over" ... "=back" regions, "=for..." paragraphs, and"=begin"..."=end" regions.

      (Pod processors must tolerate a bare "=item" as if it were "=item*".) Whether "*" is rendered as a literal asterisk, an "o", or assome kind of real bullet character, is left up to the Pod formatter,and may depend on the level of nesting.

    • An "=over" ... "=back" region containing onlym/\A=item\s+\d+\.?\s*\z/ paragraphs, each one (or each group of them)followed by some number of ordinary/verbatim paragraphs, other nested"=over" ... "=back" regions, "=for..." paragraphs, and/or"=begin"..."=end" codes. Note that the numbers must start at 1in each section, and must proceed in order and without skippingnumbers.

      (Pod processors must tolerate lines like "=item 1" as if they were"=item 1.", with the period.)

    • An "=over" ... "=back" region containing only "=item [text]"commands, each one (or each group of them) followed by some number ofordinary/verbatim paragraphs, other nested "=over" ... "=back"regions, or "=for..." paragraphs, and "=begin"..."=end" regions.

      The "=item [text]" paragraph should not matchm/\A=item\s+\d+\.?\s*\z/ or m/\A=item\s+\*\s*\z/, nor should itmatch just m/\A=item\s*\z/.

    • An "=over" ... "=back" region containing no "=item" paragraphs atall, and containing only some number of ordinary/verbatim paragraphs, and possibly also some nested "=over"... "=back" regions, "=for..." paragraphs, and "=begin"..."=end"regions. Such an itemless "=over" ... "=back" region in Pod isequivalent in meaning to a "<blockquote>...</blockquote>" element inHTML.

    Note that with all the above cases, you can determine which type of"=over" ... "=back" you have, by examining the first (non-"=cut", non-"=pod") Pod paragraph after the "=over" command.

  • Pod formatters must tolerate arbitrarily large amounts of textin the "=item text..." paragraph. In practice, most suchparagraphs are short, as in:

    1. =item For cutting off our trade with all parts of the world

    But they may be arbitrarily long:

    1. =item For transporting us beyond seas to be tried for pretended
    2. offenses
    3. =item He is at this time transporting large armies of foreign
    4. mercenaries to complete the works of death, desolation and
    5. tyranny, already begun with circumstances of cruelty and perfidy
    6. scarcely paralleled in the most barbarous ages, and totally
    7. unworthy the head of a civilized nation.
  • Pod processors should tolerate "=item *" / "=item number" commandswith no accompanying paragraph. The middle item is an example:

    1. =over
    2. =item 1
    3. Pick up dry cleaning.
    4. =item 2
    5. =item 3
    6. Stop by the store. Get Abba Zabas, Stoli, and cheap lawn chairs.
    7. =back
  • No "=over" ... "=back" region can contain headings. Processors maytreat such a heading as an error.

  • Note that an "=over" ... "=back" region should have somecontent. That is, authors should not have an empty region like this:

    1. =over
    2. =back

    Pod processors seeing such a contentless "=over" ... "=back" region,may ignore it, or may report it as an error.

  • Processors must tolerate an "=over" list that goes off the end of thedocument (i.e., which has no matching "=back"), but they may warnabout such a list.

  • Authors of Pod formatters should note that this construct:

    1. =item Neque
    2. =item Porro
    3. =item Quisquam Est
    4. Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
    5. velit, sed quia non numquam eius modi tempora incidunt ut
    6. labore et dolore magnam aliquam quaerat voluptatem.
    7. =item Ut Enim

    is semantically ambiguous, in a way that makes formatting decisionsa bit difficult. On the one hand, it could be mention of an item"Neque", mention of another item "Porro", and mention of anotheritem "Quisquam Est", with just the last one requiring the explanatoryparagraph "Qui dolorem ipsum quia dolor..."; and then an item"Ut Enim". In that case, you'd want to format it like so:

    1. Neque
    2. Porro
    3. Quisquam Est
    4. Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
    5. velit, sed quia non numquam eius modi tempora incidunt ut
    6. labore et dolore magnam aliquam quaerat voluptatem.
    7. Ut Enim

    But it could equally well be a discussion of three (related or equivalent)items, "Neque", "Porro", and "Quisquam Est", followed by a paragraphexplaining them all, and then a new item "Ut Enim". In that case, you'dprobably want to format it like so:

    1. Neque
    2. Porro
    3. Quisquam Est
    4. Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
    5. velit, sed quia non numquam eius modi tempora incidunt ut
    6. labore et dolore magnam aliquam quaerat voluptatem.
    7. Ut Enim

    But (for the foreseeable future), Pod does not provide any way for Podauthors to distinguish which grouping is meant by the above"=item"-cluster structure. So formatters should format it like so:

    1. Neque
    2. Porro
    3. Quisquam Est
    4. Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
    5. velit, sed quia non numquam eius modi tempora incidunt ut
    6. labore et dolore magnam aliquam quaerat voluptatem.
    7. Ut Enim

    That is, there should be (at least roughly) equal spacing betweenitems as between paragraphs (although that spacing may well be lessthan the full height of a line of text). This leaves it to the readerto use (con)textual cues to figure out whether the "Qui doloremipsum..." paragraph applies to the "Quisquam Est" item or to all threeitems "Neque", "Porro", and "Quisquam Est". While not an idealsituation, this is preferable to providing formatting cues that maybe actually contrary to the author's intent.

About Data Paragraphs and "=begin/=end" Regions

Data paragraphs are typically used for inlining non-Pod data that isto be used (typically passed through) when rendering the document toa specific format:

  1. =begin rtf
  2. \par{\pard\qr\sa4500{\i Printed\~\chdate\~\chtime}\par}
  3. =end rtf

The exact same effect could, incidentally, be achieved with a single"=for" paragraph:

  1. =for rtf \par{\pard\qr\sa4500{\i Printed\~\chdate\~\chtime}\par}

(Although that is not formally a data paragraph, it has the samemeaning as one, and Pod parsers may parse it as one.)

Another example of a data paragraph:

  1. =begin html
  2. I like <em>PIE</em>!
  3. <hr>Especially pecan pie!
  4. =end html

If these were ordinary paragraphs, the Pod parser would try toexpand the "E</em>" (in the first paragraph) as a formattingcode, just like "E<lt>" or "E<eacute>". But since thisis in a "=begin identifier"..."=end identifier" region andthe identifier "html" doesn't begin have a ":" prefix, the contentsof this region are stored as data paragraphs, instead of beingprocessed as ordinary paragraphs (or if they began with a spacesand/or tabs, as verbatim paragraphs).

As a further example: At time of writing, no "biblio" identifier issupported, but suppose some processor were written to recognize it asa way of (say) denoting a bibliographic reference (necessarilycontaining formatting codes in ordinary paragraphs). The fact that"biblio" paragraphs were meant for ordinary processing would beindicated by prefacing each "biblio" identifier with a colon:

  1. =begin :biblio
  2. Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
  3. Programs.> Prentice-Hall, Englewood Cliffs, NJ.
  4. =end :biblio

This would signal to the parser that paragraphs in this begin...endregion are subject to normal handling as ordinary/verbatim paragraphs(while still tagged as meant only for processors that understand the"biblio" identifier). The same effect could be had with:

  1. =for :biblio
  2. Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
  3. Programs.> Prentice-Hall, Englewood Cliffs, NJ.

The ":" on these identifiers means simply "process this stuffnormally, even though the result will be for some special target".I suggest that parser APIs report "biblio" as the target identifier,but also report that it had a ":" prefix. (And similarly, with theabove "html", report "html" as the target identifier, and note thelack of a ":" prefix.)

Note that a "=begin identifier"..."=end identifier" region whereidentifier begins with a colon, can contain commands. For example:

  1. =begin :biblio
  2. Wirth's classic is available in several editions, including:
  3. =for comment
  4. hm, check abebooks.com for how much used copies cost.
  5. =over
  6. =item
  7. Wirth, Niklaus. 1975. I<Algorithmen und Datenstrukturen.>
  8. Teubner, Stuttgart. [Yes, it's in German.]
  9. =item
  10. Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
  11. Programs.> Prentice-Hall, Englewood Cliffs, NJ.
  12. =back
  13. =end :biblio

Note, however, a "=begin identifier"..."=end identifier"region where identifier does not begin with a colon, should notdirectly contain "=head1" ... "=head4" commands, nor "=over", nor "=back",nor "=item". For example, this may be considered invalid:

  1. =begin somedata
  2. This is a data paragraph.
  3. =head1 Don't do this!
  4. This is a data paragraph too.
  5. =end somedata

A Pod processor may signal that the above (specifically the "=head1"paragraph) is an error. Note, however, that the following shouldnot be treated as an error:

  1. =begin somedata
  2. This is a data paragraph.
  3. =cut
  4. # Yup, this isn't Pod anymore.
  5. sub excl { (rand() > .5) ? "hoo!" : "hah!" }
  6. =pod
  7. This is a data paragraph too.
  8. =end somedata

And this too is valid:

  1. =begin someformat
  2. This is a data paragraph.
  3. And this is a data paragraph.
  4. =begin someotherformat
  5. This is a data paragraph too.
  6. And this is a data paragraph too.
  7. =begin :yetanotherformat
  8. =head2 This is a command paragraph!
  9. This is an ordinary paragraph!
  10. And this is a verbatim paragraph!
  11. =end :yetanotherformat
  12. =end someotherformat
  13. Another data paragraph!
  14. =end someformat

The contents of the above "=begin :yetanotherformat" ..."=end :yetanotherformat" region aren't data paragraphs, becausethe immediately containing region's identifier (":yetanotherformat")begins with a colon. In practice, most regions that containdata paragraphs will contain only data paragraphs; however, the above nesting is syntactically valid as Pod, even if it israre. However, the handlers for some formats, like "html",will accept only data paragraphs, not nested regions; and they maycomplain if they see (targeted for them) nested regions, or commands,other than "=end", "=pod", and "=cut".

Also consider this valid structure:

  1. =begin :biblio
  2. Wirth's classic is available in several editions, including:
  3. =over
  4. =item
  5. Wirth, Niklaus. 1975. I<Algorithmen und Datenstrukturen.>
  6. Teubner, Stuttgart. [Yes, it's in German.]
  7. =item
  8. Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
  9. Programs.> Prentice-Hall, Englewood Cliffs, NJ.
  10. =back
  11. Buy buy buy!
  12. =begin html
  13. <img src='wirth_spokesmodeling_book.png'>
  14. <hr>
  15. =end html
  16. Now now now!
  17. =end :biblio

There, the "=begin html"..."=end html" region is nested insidethe larger "=begin :biblio"..."=end :biblio" region. Note that thecontent of the "=begin html"..."=end html" region is dataparagraph(s), because the immediately containing region's identifier("html") doesn't begin with a colon.

Pod parsers, when processing a series of data paragraphs oneafter another (within a single region), should consider them tobe one large data paragraph that happens to contain blank lines. Sothe content of the above "=begin html"..."=end html" may be storedas two data paragraphs (one consisting of"<img src='wirth_spokesmodeling_book.png'>\n"and another consisting of "<hr>\n"), but should be stored asa single data paragraph (consisting of "<img src='wirth_spokesmodeling_book.png'>\n\n<hr>\n").

Pod processors should tolerate empty"=begin something"..."=end something" regions,empty "=begin :something"..."=end :something" regions, andcontentless "=for something" and "=for :something"paragraphs. I.e., these should be tolerated:

  1. =for html
  2. =begin html
  3. =end html
  4. =begin :biblio
  5. =end :biblio

Incidentally, note that there's no easy way to express a dataparagraph starting with something that looks like a command. Consider:

  1. =begin stuff
  2. =shazbot
  3. =end stuff

There, "=shazbot" will be parsed as a Pod command "shazbot", not as a dataparagraph "=shazbot\n". However, you can express a data paragraph consistingof "=shazbot\n" using this code:

  1. =for stuff =shazbot

The situation where this is necessary, is presumably quite rare.

Note that =end commands must match the currently open =begin command. Thatis, they must properly nest. For example, this is valid:

  1. =begin outer
  2. X
  3. =begin inner
  4. Y
  5. =end inner
  6. Z
  7. =end outer

while this is invalid:

  1. =begin outer
  2. X
  3. =begin inner
  4. Y
  5. =end outer
  6. Z
  7. =end inner

This latter is improper because when the "=end outer" command is seen, thecurrently open region has the formatname "inner", not "outer". (It justhappens that "outer" is the format name of a higher-up region.) This isan error. Processors must by default report this as an error, and may haltprocessing the document containing that error. A corollary of this is thatregions cannot "overlap". That is, the latter block above does not representa region called "outer" which contains X and Y, overlapping a region called"inner" which contains Y and Z. But because it is invalid (as allapparently overlapping regions would be), it doesn't represent that, oranything at all.

Similarly, this is invalid:

  1. =begin thing
  2. =end hting

This is an error because the region is opened by "thing", and the "=end"tries to close "hting" [sic].

This is also invalid:

  1. =begin thing
  2. =end

This is invalid because every "=end" command must have a formatnameparameter.

SEE ALSO

perlpod, PODs: Embedded Documentation in perlsyn,podchecker

AUTHOR

Sean M. Burke

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) POD plain old documentationPerl POD style guide (Berikutnya)