1PERLPODSPEC(1)         Perl Programmers Reference Guide         PERLPODSPEC(1)
2
3
4

NAME

6       perlpodspec - Plain Old Documentation: format specification and notes
7

DESCRIPTION

9       This document is detailed notes on the Pod markup language.  Most
10       people will only have to read perlpod to know how to write in Pod, but
11       this document may answer some incidental questions to do with parsing
12       and rendering Pod.
13
14       In this document, "must" / "must not", "should" / "should not", and
15       "may" have their conventional (cf. RFC 2119) meanings: "X must do Y"
16       means that if X doesn't do Y, it's against this specification, and
17       should really be fixed.  "X should do Y" means that it's recommended,
18       but X may fail to do Y, if there's a good reason.  "X may do Y" is
19       merely a note that X can do Y at will (although it is up to the reader
20       to detect any connotation of "and I think it would be nice if X did Y"
21       versus "it wouldn't really bother me if X did Y").
22
23       Notably, when I say "the parser should do Y", the parser may fail to do
24       Y, if the calling application explicitly requests that the parser not
25       do Y.  I often phrase this as "the parser should, by default, do Y."
26       This doesn't require the parser to provide an option for turning off
27       whatever feature Y is (like expanding tabs in verbatim paragraphs),
28       although it implicates that such an option may be provided.
29

Pod Definitions

31       Pod is embedded in files, typically Perl source files, although you can
32       write a file that's nothing but Pod.
33
34       A line in a file consists of zero or more non-newline characters,
35       terminated by either a newline or the end of the file.
36
37       A newline sequence is usually a platform-dependent concept, but Pod
38       parsers should understand it to mean any of CR (ASCII 13), LF (ASCII
39       10), or a CRLF (ASCII 13 followed immediately by ASCII 10), in addition
40       to any other system-specific meaning.  The first CR/CRLF/LF sequence in
41       the file may be used as the basis for identifying the newline sequence
42       for parsing the rest of the file.
43
44       A blank line is a line consisting entirely of zero or more spaces
45       (ASCII 32) or tabs (ASCII 9), and terminated by a newline or end-of-
46       file.  A non-blank line is a line containing one or more characters
47       other than space or tab (and terminated by a newline or end-of-file).
48
49       (Note: Many older Pod parsers did not accept a line consisting of
50       spaces/tabs and then a newline as a blank line. The only lines they
51       considered blank were lines consisting of no characters at all,
52       terminated by a newline.)
53
54       Whitespace is used in this document as a blanket term for spaces, tabs,
55       and newline sequences.  (By itself, this term usually refers to literal
56       whitespace.  That is, sequences of whitespace characters in Pod source,
57       as opposed to "E<32>", which is a formatting code that denotes a
58       whitespace character.)
59
60       A Pod parser is a module meant for parsing Pod (regardless of whether
61       this involves calling callbacks or building a parse tree or directly
62       formatting it).  A Pod formatter (or Pod translator) is a module or
63       program that converts Pod to some other format (HTML, plaintext, TeX,
64       PostScript, RTF).  A Pod processor might be a formatter or translator,
65       or might be a program that does something else with the Pod (like
66       counting words, scanning for index points, etc.).
67
68       Pod content is contained in Pod blocks.  A Pod block starts with a line
69       that matches <m/\A=[a-zA-Z]/>, and continues up to the next line that
70       matches "m/\A=cut/" or up to the end of the file if there is no
71       "m/\A=cut/" line.
72
73       Within a Pod block, there are Pod paragraphs.  A Pod paragraph consists
74       of non-blank lines of text, separated by one or more blank lines.
75
76       For purposes of Pod processing, there are four types of paragraphs in a
77       Pod block:
78
79       ·   A command paragraph (also called a "directive").  The first line of
80           this paragraph must match "m/\A=[a-zA-Z]/".  Command paragraphs are
81           typically one line, as in:
82
83             =head1 NOTES
84
85             =item *
86
87           But they may span several (non-blank) lines:
88
89             =for comment
90             Hm, I wonder what it would look like if
91             you tried to write a BNF for Pod from this.
92
93             =head3 Dr. Strangelove, or: How I Learned to
94             Stop Worrying and Love the Bomb
95
96           Some command paragraphs allow formatting codes in their content
97           (i.e., after the part that matches "m/\A=[a-zA-Z]\S*\s*/"), as in:
98
99             =head1 Did You Remember to C<use strict;>?
100
101           In other words, the Pod processing handler for "head1" will apply
102           the same processing to "Did You Remember to C<use strict;>?" that
103           it would to an ordinary paragraph (i.e., formatting codes like
104           "C<...>") are parsed and presumably formatted appropriately, and
105           whitespace in the form of literal spaces and/or tabs is not
106           significant.
107
108       ·   A verbatim paragraph.  The first line of this paragraph must be a
109           literal space or tab, and this paragraph must not be inside a
110           "=begin identifier", ... "=end identifier" sequence unless
111           "identifier" begins with a colon (":").  That is, if a paragraph
112           starts with a literal space or tab, but is inside a "=begin
113           identifier", ... "=end identifier" region, then it's a data
114           paragraph, unless "identifier" begins with a colon.
115
116           Whitespace is significant in verbatim paragraphs (although, in
117           processing, tabs are probably expanded).
118
119       ·   An ordinary paragraph.  A paragraph is an ordinary paragraph if its
120           first line matches neither "m/\A=[a-zA-Z]/" nor "m/\A[ \t]/", and
121           if it's not inside a "=begin identifier", ... "=end identifier"
122           sequence unless "identifier" begins with a colon (":").
123
124       ·   A data paragraph.  This is a paragraph that is inside a "=begin
125           identifier" ... "=end identifier" sequence where "identifier" does
126           not begin with a literal colon (":").  In some sense, a data
127           paragraph is not part of Pod at all (i.e., effectively it's "out-
128           of-band"), since it's not subject to most kinds of Pod parsing; but
129           it is specified here, since Pod parsers need to be able to call an
130           event for it, or store it in some form in a parse tree, or at least
131           just parse around it.
132
133       For example: consider the following paragraphs:
134
135         # <- that's the 0th column
136
137         =head1 Foo
138
139         Stuff
140
141           $foo->bar
142
143         =cut
144
145       Here, "=head1 Foo" and "=cut" are command paragraphs because the first
146       line of each matches "m/\A=[a-zA-Z]/".  "[space][space]$foo->bar" is a
147       verbatim paragraph, because its first line starts with a literal
148       whitespace character (and there's no "=begin"..."=end" region around).
149
150       The "=begin identifier" ... "=end identifier" commands stop paragraphs
151       that they surround from being parsed as ordinary or verbatim
152       paragraphs, if identifier doesn't begin with a colon.  This is
153       discussed in detail in the section "About Data Paragraphs and
154       "=begin/=end" Regions".
155

Pod Commands

157       This section is intended to supplement and clarify the discussion in
158       "Command Paragraph" in perlpod.  These are the currently recognized Pod
159       commands:
160
161       "=head1", "=head2", "=head3", "=head4"
162           This command indicates that the text in the remainder of the
163           paragraph is a heading.  That text may contain formatting codes.
164           Examples:
165
166             =head1 Object Attributes
167
168             =head3 What B<Not> to Do!
169
170       "=pod"
171           This command indicates that this paragraph begins a Pod block.  (If
172           we are already in the middle of a Pod block, this command has no
173           effect at all.)  If there is any text in this command paragraph
174           after "=pod", it must be ignored.  Examples:
175
176             =pod
177
178             This is a plain Pod paragraph.
179
180             =pod This text is ignored.
181
182       "=cut"
183           This command indicates that this line is the end of this previously
184           started Pod block.  If there is any text after "=cut" on the line,
185           it must be ignored.  Examples:
186
187             =cut
188
189             =cut The documentation ends here.
190
191             =cut
192             # This is the first line of program text.
193             sub foo { # This is the second.
194
195           It is an error to try to start a Pod block with a "=cut" command.
196           In that case, the Pod processor must halt parsing of the input
197           file, and must by default emit a warning.
198
199       "=over"
200           This command indicates that this is the start of a list/indent
201           region.  If there is any text following the "=over", it must
202           consist of only a nonzero positive numeral.  The semantics of this
203           numeral is explained in the "About =over...=back Regions" section,
204           further below.  Formatting codes are not expanded.  Examples:
205
206             =over 3
207
208             =over 3.5
209
210             =over
211
212       "=item"
213           This command indicates that an item in a list begins here.
214           Formatting codes are processed.  The semantics of the (optional)
215           text in the remainder of this paragraph are explained in the "About
216           =over...=back Regions" section, further below.  Examples:
217
218             =item
219
220             =item *
221
222             =item      *
223
224             =item 14
225
226             =item   3.
227
228             =item C<< $thing->stuff(I<dodad>) >>
229
230             =item For transporting us beyond seas to be tried for pretended
231             offenses
232
233             =item He is at this time transporting large armies of foreign
234             mercenaries to complete the works of death, desolation and
235             tyranny, already begun with circumstances of cruelty and perfidy
236             scarcely paralleled in the most barbarous ages, and totally
237             unworthy the head of a civilized nation.
238
239       "=back"
240           This command indicates that this is the end of the region begun by
241           the most recent "=over" command.  It permits no text after the
242           "=back" command.
243
244       "=begin formatname"
245       "=begin formatname parameter"
246           This marks the following paragraphs (until the matching "=end
247           formatname") as being for some special kind of processing.  Unless
248           "formatname" begins with a colon, the contained non-command
249           paragraphs are data paragraphs.  But if "formatname" does begin
250           with a colon, then non-command paragraphs are ordinary paragraphs
251           or data paragraphs.  This is discussed in detail in the section
252           "About Data Paragraphs and "=begin/=end" Regions".
253
254           It is advised that formatnames match the regexp
255           "m/\A:?[-a-zA-Z0-9_]+\z/".  Everything following whitespace after
256           the formatname is a parameter that may be used by the formatter
257           when dealing with this region.  This parameter must not be repeated
258           in the "=end" paragraph.  Implementors should anticipate future
259           expansion in the semantics and syntax of the first parameter to
260           "=begin"/"=end"/"=for".
261
262       "=end formatname"
263           This marks the end of the region opened by the matching "=begin
264           formatname" region.  If "formatname" is not the formatname of the
265           most recent open "=begin formatname" region, then this is an error,
266           and must generate an error message.  This is discussed in detail in
267           the section "About Data Paragraphs and "=begin/=end" Regions".
268
269       "=for formatname text..."
270           This is synonymous with:
271
272                =begin formatname
273
274                text...
275
276                =end formatname
277
278           That is, it creates a region consisting of a single paragraph; that
279           paragraph is to be treated as a normal paragraph if "formatname"
280           begins with a ":"; if "formatname" doesn't begin with a colon, then
281           "text..." will constitute a data paragraph.  There is no way to use
282           "=for formatname text..." to express "text..." as a verbatim
283           paragraph.
284
285       "=encoding encodingname"
286           This command, which should occur early in the document (at least
287           before any non-US-ASCII data!), declares that this document is
288           encoded in the encoding encodingname, which must be an encoding
289           name that Encode recognizes.  (Encode's list of supported
290           encodings, in Encode::Supported, is useful here.)  If the Pod
291           parser cannot decode the declared encoding, it should emit a
292           warning and may abort parsing the document altogether.
293
294           A document having more than one "=encoding" line should be
295           considered an error.  Pod processors may silently tolerate this if
296           the not-first "=encoding" lines are just duplicates of the first
297           one (e.g., if there's a "=encoding utf8" line, and later on another
298           "=encoding utf8" line).  But Pod processors should complain if
299           there are contradictory "=encoding" lines in the same document
300           (e.g., if there is a "=encoding utf8" early in the document and
301           "=encoding big5" later).  Pod processors that recognize BOMs may
302           also complain if they see an "=encoding" line that contradicts the
303           BOM (e.g., if a document with a UTF-16LE BOM has an "=encoding
304           shiftjis" line).
305
306       If a Pod processor sees any command other than the ones listed above
307       (like "=head", or "=haed1", or "=stuff", or "=cuttlefish", or "=w123"),
308       that processor must by default treat this as an error.  It must not
309       process the paragraph beginning with that command, must by default warn
310       of this as an error, and may abort the parse.  A Pod parser may allow a
311       way for particular applications to add to the above list of known
312       commands, and to stipulate, for each additional command, whether
313       formatting codes should be processed.
314
315       Future versions of this specification may add additional commands.
316

Pod Formatting Codes

318       (Note that in previous drafts of this document and of perlpod,
319       formatting codes were referred to as "interior sequences", and this
320       term may still be found in the documentation for Pod parsers, and in
321       error messages from Pod processors.)
322
323       There are two syntaxes for formatting codes:
324
325       ·   A formatting code starts with a capital letter (just US-ASCII
326           [A-Z]) followed by a "<", any number of characters, and ending with
327           the first matching ">".  Examples:
328
329               That's what I<you> think!
330
331               What's C<dump()> for?
332
333               X<C<chmod> and C<unlink()> Under Different Operating Systems>
334
335       ·   A formatting code starts with a capital letter (just US-ASCII
336           [A-Z]) followed by two or more "<"'s, one or more whitespace
337           characters, any number of characters, one or more whitespace
338           characters, and ending with the first matching sequence of two or
339           more ">"'s, where the number of ">"'s equals the number of "<"'s in
340           the opening of this formatting code.  Examples:
341
342               That's what I<< you >> think!
343
344               C<<< open(X, ">>thing.dat") || die $! >>>
345
346               B<< $foo->bar(); >>
347
348           With this syntax, the whitespace character(s) after the "C<<<" and
349           before the ">>" (or whatever letter) are not renderable. They do
350           not signify whitespace, are merely part of the formatting codes
351           themselves.  That is, these are all synonymous:
352
353               C<thing>
354               C<< thing >>
355               C<<           thing     >>
356               C<<<   thing >>>
357               C<<<<
358               thing
359                          >>>>
360
361           and so on.
362
363           Finally, the multiple-angle-bracket form does not alter the
364           interpretation of nested formatting codes, meaning that the
365           following four example lines are identical in meaning:
366
367             B<example: C<$a E<lt>=E<gt> $b>>
368
369             B<example: C<< $a <=> $b >>>
370
371             B<example: C<< $a E<lt>=E<gt> $b >>>
372
373             B<<< example: C<< $a E<lt>=E<gt> $b >> >>>
374
375       In parsing Pod, a notably tricky part is the correct parsing of
376       (potentially nested!) formatting codes.  Implementors should consult
377       the code in the "parse_text" routine in Pod::Parser as an example of a
378       correct implementation.
379
380       "I<text>" -- italic text
381           See the brief discussion in "Formatting Codes" in perlpod.
382
383       "B<text>" -- bold text
384           See the brief discussion in "Formatting Codes" in perlpod.
385
386       "C<code>" -- code text
387           See the brief discussion in "Formatting Codes" in perlpod.
388
389       "F<filename>" -- style for filenames
390           See the brief discussion in "Formatting Codes" in perlpod.
391
392       "X<topic name>" -- an index entry
393           See the brief discussion in "Formatting Codes" in perlpod.
394
395           This code is unusual in that most formatters completely discard
396           this code and its content.  Other formatters will render it with
397           invisible codes that can be used in building an index of the
398           current document.
399
400       "Z<>" -- a null (zero-effect) formatting code
401           Discussed briefly in "Formatting Codes" in perlpod.
402
403           This code is unusual is that it should have no content.  That is, a
404           processor may complain if it sees "Z<potatoes>".  Whether or not it
405           complains, the potatoes text should ignored.
406
407       "L<name>" -- a hyperlink
408           The complicated syntaxes of this code are discussed at length in
409           "Formatting Codes" in perlpod, and implementation details are
410           discussed below, in "About L<...> Codes".  Parsing the contents of
411           L<content> is tricky.  Notably, the content has to be checked for
412           whether it looks like a URL, or whether it has to be split on
413           literal "|" and/or "/" (in the right order!), and so on, before
414           E<...> codes are resolved.
415
416       "E<escape>" -- a character escape
417           See "Formatting Codes" in perlpod, and several points in "Notes on
418           Implementing Pod Processors".
419
420       "S<text>" -- text contains non-breaking spaces
421           This formatting code is syntactically simple, but semantically
422           complex.  What it means is that each space in the printable content
423           of this code signifies a non-breaking space.
424
425           Consider:
426
427               C<$x ? $y    :  $z>
428
429               S<C<$x ? $y     :  $z>>
430
431           Both signify the monospace (c[ode] style) text consisting of "$x",
432           one space, "?", one space, ":", one space, "$z".  The difference is
433           that in the latter, with the S code, those spaces are not "normal"
434           spaces, but instead are non-breaking spaces.
435
436       If a Pod processor sees any formatting code other than the ones listed
437       above (as in "N<...>", or "Q<...>", etc.), that processor must by
438       default treat this as an error.  A Pod parser may allow a way for
439       particular applications to add to the above list of known formatting
440       codes; a Pod parser might even allow a way to stipulate, for each
441       additional command, whether it requires some form of special
442       processing, as L<...> does.
443
444       Future versions of this specification may add additional formatting
445       codes.
446
447       Historical note:  A few older Pod processors would not see a ">" as
448       closing a "C<" code, if the ">" was immediately preceded by a "-".
449       This was so that this:
450
451           C<$foo->bar>
452
453       would parse as equivalent to this:
454
455           C<$foo-E<gt>bar>
456
457       instead of as equivalent to a "C" formatting code containing only
458       "$foo-", and then a "bar>" outside the "C" formatting code.  This
459       problem has since been solved by the addition of syntaxes like this:
460
461           C<< $foo->bar >>
462
463       Compliant parsers must not treat "->" as special.
464
465       Formatting codes absolutely cannot span paragraphs.  If a code is
466       opened in one paragraph, and no closing code is found by the end of
467       that paragraph, the Pod parser must close that formatting code, and
468       should complain (as in "Unterminated I code in the paragraph starting
469       at line 123: 'Time objects are not...'").  So these two paragraphs:
470
471         I<I told you not to do this!
472
473         Don't make me say it again!>
474
475       ...must not be parsed as two paragraphs in italics (with the I code
476       starting in one paragraph and starting in another.)  Instead, the first
477       paragraph should generate a warning, but that aside, the above code
478       must parse as if it were:
479
480         I<I told you not to do this!>
481
482         Don't make me say it again!E<gt>
483
484       (In SGMLish jargon, all Pod commands are like block-level elements,
485       whereas all Pod formatting codes are like inline-level elements.)
486

Notes on Implementing Pod Processors

488       The following is a long section of miscellaneous requirements and
489       suggestions to do with Pod processing.
490
491       ·   Pod formatters should tolerate lines in verbatim blocks that are of
492           any length, even if that means having to break them (possibly
493           several times, for very long lines) to avoid text running off the
494           side of the page.  Pod formatters may warn of such line-breaking.
495           Such warnings are particularly appropriate for lines are over 100
496           characters long, which are usually not intentional.
497
498       ·   Pod parsers must recognize all of the three well-known newline
499           formats: CR, LF, and CRLF.  See perlport.
500
501       ·   Pod parsers should accept input lines that are of any length.
502
503       ·   Since Perl recognizes a Unicode Byte Order Mark at the start of
504           files as signaling that the file is Unicode encoded as in UTF-16
505           (whether big-endian or little-endian) or UTF-8, Pod parsers should
506           do the same.  Otherwise, the character encoding should be
507           understood as being UTF-8 if the first highbit byte sequence in the
508           file seems valid as a UTF-8 sequence, or otherwise as Latin-1.
509
510           Future versions of this specification may specify how Pod can
511           accept other encodings.  Presumably treatment of other encodings in
512           Pod parsing would be as in XML parsing: whatever the encoding
513           declared by a particular Pod file, content is to be stored in
514           memory as Unicode characters.
515
516       ·   The well known Unicode Byte Order Marks are as follows:  if the
517           file begins with the two literal byte values 0xFE 0xFF, this is the
518           BOM for big-endian UTF-16.  If the file begins with the two literal
519           byte value 0xFF 0xFE, this is the BOM for little-endian UTF-16.  If
520           the file begins with the three literal byte values 0xEF 0xBB 0xBF,
521           this is the BOM for UTF-8.
522
523       ·   A naive but sufficient heuristic for testing the first highbit
524           byte-sequence in a BOM-less file (whether in code or in Pod!), to
525           see whether that sequence is valid as UTF-8 (RFC 2279) is to check
526           whether that the first byte in the sequence is in the range 0xC0 -
527           0xFD and whether the next byte is in the range 0x80 - 0xBF.  If so,
528           the parser may conclude that this file is in UTF-8, and all highbit
529           sequences in the file should be assumed to be UTF-8.  Otherwise the
530           parser should treat the file as being in Latin-1.  In the unlikely
531           circumstance that the first highbit sequence in a truly non-UTF-8
532           file happens to appear to be UTF-8, one can cater to our heuristic
533           (as well as any more intelligent heuristic) by prefacing that line
534           with a comment line containing a highbit sequence that is clearly
535           not valid as UTF-8.  A line consisting of simply "#", an e-acute,
536           and any non-highbit byte, is sufficient to establish this file's
537           encoding.
538
539       ·   This document's requirements and suggestions about encodings do not
540           apply to Pod processors running on non-ASCII platforms, notably
541           EBCDIC platforms.
542
543       ·   Pod processors must treat a "=for [label] [content...]" paragraph
544           as meaning the same thing as a "=begin [label]" paragraph, content,
545           and an "=end [label]" paragraph.  (The parser may conflate these
546           two constructs, or may leave them distinct, in the expectation that
547           the formatter will nevertheless treat them the same.)
548
549       ·   When rendering Pod to a format that allows comments (i.e., to
550           nearly any format other than plaintext), a Pod formatter must
551           insert comment text identifying its name and version number, and
552           the name and version numbers of any modules it might be using to
553           process the Pod.  Minimal examples:
554
555             %% POD::Pod2PS v3.14159, using POD::Parser v1.92
556
557             <!-- Pod::HTML v3.14159, using POD::Parser v1.92 -->
558
559             {\doccomm generated by Pod::Tree::RTF 3.14159 using Pod::Tree 1.08}
560
561             .\" Pod::Man version 3.14159, using POD::Parser version 1.92
562
563           Formatters may also insert additional comments, including: the
564           release date of the Pod formatter program, the contact address for
565           the author(s) of the formatter, the current time, the name of input
566           file, the formatting options in effect, version of Perl used, etc.
567
568           Formatters may also choose to note errors/warnings as comments,
569           besides or instead of emitting them otherwise (as in messages to
570           STDERR, or "die"ing).
571
572       ·   Pod parsers may emit warnings or error messages ("Unknown E code
573           E<zslig>!") to STDERR (whether through printing to STDERR, or
574           "warn"ing/"carp"ing, or "die"ing/"croak"ing), but must allow
575           suppressing all such STDERR output, and instead allow an option for
576           reporting errors/warnings in some other way, whether by triggering
577           a callback, or noting errors in some attribute of the document
578           object, or some similarly unobtrusive mechanism -- or even by
579           appending a "Pod Errors" section to the end of the parsed form of
580           the document.
581
582       ·   In cases of exceptionally aberrant documents, Pod parsers may abort
583           the parse.  Even then, using "die"ing/"croak"ing is to be avoided;
584           where possible, the parser library may simply close the input file
585           and add text like "*** Formatting Aborted ***" to the end of the
586           (partial) in-memory document.
587
588       ·   In paragraphs where formatting codes (like E<...>, B<...>) are
589           understood (i.e., not verbatim paragraphs, but including ordinary
590           paragraphs, and command paragraphs that produce renderable text,
591           like "=head1"), literal whitespace should generally be considered
592           "insignificant", in that one literal space has the same meaning as
593           any (nonzero) number of literal spaces, literal newlines, and
594           literal tabs (as long as this produces no blank lines, since those
595           would terminate the paragraph).  Pod parsers should compact literal
596           whitespace in each processed paragraph, but may provide an option
597           for overriding this (since some processing tasks do not require
598           it), or may follow additional special rules (for example, specially
599           treating period-space-space or period-newline sequences).
600
601       ·   Pod parsers should not, by default, try to coerce apostrophe (')
602           and quote (") into smart quotes (little 9's, 66's, 99's, etc), nor
603           try to turn backtick (`) into anything else but a single backtick
604           character (distinct from an open quote character!), nor "--" into
605           anything but two minus signs.  They must never do any of those
606           things to text in C<...> formatting codes, and never ever to text
607           in verbatim paragraphs.
608
609       ·   When rendering Pod to a format that has two kinds of hyphens (-),
610           one that's a non-breaking hyphen, and another that's a breakable
611           hyphen (as in "object-oriented", which can be split across lines as
612           "object-", newline, "oriented"), formatters are encouraged to
613           generally translate "-" to non-breaking hyphen, but may apply
614           heuristics to convert some of these to breaking hyphens.
615
616       ·   Pod formatters should make reasonable efforts to keep words of Perl
617           code from being broken across lines.  For example, "Foo::Bar" in
618           some formatting systems is seen as eligible for being broken across
619           lines as "Foo::" newline "Bar" or even "Foo::-" newline "Bar".
620           This should be avoided where possible, either by disabling all
621           line-breaking in mid-word, or by wrapping particular words with
622           internal punctuation in "don't break this across lines" codes
623           (which in some formats may not be a single code, but might be a
624           matter of inserting non-breaking zero-width spaces between every
625           pair of characters in a word.)
626
627       ·   Pod parsers should, by default, expand tabs in verbatim paragraphs
628           as they are processed, before passing them to the formatter or
629           other processor.  Parsers may also allow an option for overriding
630           this.
631
632       ·   Pod parsers should, by default, remove newlines from the end of
633           ordinary and verbatim paragraphs before passing them to the
634           formatter.  For example, while the paragraph you're reading now
635           could be considered, in Pod source, to end with (and contain) the
636           newline(s) that end it, it should be processed as ending with (and
637           containing) the period character that ends this sentence.
638
639       ·   Pod parsers, when reporting errors, should make some effort to
640           report an approximate line number ("Nested E<>'s in Paragraph #52,
641           near line 633 of Thing/Foo.pm!"), instead of merely noting the
642           paragraph number ("Nested E<>'s in Paragraph #52 of
643           Thing/Foo.pm!").  Where this is problematic, the paragraph number
644           should at least be accompanied by an excerpt from the paragraph
645           ("Nested E<>'s in Paragraph #52 of Thing/Foo.pm, which begins
646           'Read/write accessor for the C<interest rate> attribute...'").
647
648       ·   Pod parsers, when processing a series of verbatim paragraphs one
649           after another, should consider them to be one large verbatim
650           paragraph that happens to contain blank lines.  I.e., these two
651           lines, which have a blank line between them:
652
653                   use Foo;
654
655                   print Foo->VERSION
656
657           should be unified into one paragraph ("\tuse Foo;\n\n\tprint
658           Foo->VERSION") before being passed to the formatter or other
659           processor.  Parsers may also allow an option for overriding this.
660
661           While this might be too cumbersome to implement in event-based Pod
662           parsers, it is straightforward for parsers that return parse trees.
663
664       ·   Pod formatters, where feasible, are advised to avoid splitting
665           short verbatim paragraphs (under twelve lines, say) across pages.
666
667       ·   Pod parsers must treat a line with only spaces and/or tabs on it as
668           a "blank line" such as separates paragraphs.  (Some older parsers
669           recognized only two adjacent newlines as a "blank line" but would
670           not recognize a newline, a space, and a newline, as a blank line.
671           This is noncompliant behavior.)
672
673       ·   Authors of Pod formatters/processors should make every effort to
674           avoid writing their own Pod parser.  There are already several in
675           CPAN, with a wide range of interface styles -- and one of them,
676           Pod::Parser, comes with modern versions of Perl.
677
678       ·   Characters in Pod documents may be conveyed either as literals, or
679           by number in E<n> codes, or by an equivalent mnemonic, as in
680           E<eacute> which is exactly equivalent to E<233>.
681
682           Characters in the range 32-126 refer to those well known US-ASCII
683           characters (also defined there by Unicode, with the same meaning),
684           which all Pod formatters must render faithfully.  Characters in the
685           ranges 0-31 and 127-159 should not be used (neither as literals,
686           nor as E<number> codes), except for the literal byte-sequences for
687           newline (13, 13 10, or 10), and tab (9).
688
689           Characters in the range 160-255 refer to Latin-1 characters (also
690           defined there by Unicode, with the same meaning).  Characters above
691           255 should be understood to refer to Unicode characters.
692
693       ·   Be warned that some formatters cannot reliably render characters
694           outside 32-126; and many are able to handle 32-126 and 160-255, but
695           nothing above 255.
696
697       ·   Besides the well-known "E<lt>" and "E<gt>" codes for less-than and
698           greater-than, Pod parsers must understand "E<sol>" for "/"
699           (solidus, slash), and "E<verbar>" for "|" (vertical bar, pipe).
700           Pod parsers should also understand "E<lchevron>" and "E<rchevron>"
701           as legacy codes for characters 171 and 187, i.e., "left-pointing
702           double angle quotation mark" = "left pointing guillemet" and
703           "right-pointing double angle quotation mark" = "right pointing
704           guillemet".  (These look like little "<<" and ">>", and they are
705           now preferably expressed with the HTML/XHTML codes "E<laquo>" and
706           "E<raquo>".)
707
708       ·   Pod parsers should understand all "E<html>" codes as defined in the
709           entity declarations in the most recent XHTML specification at
710           "www.W3.org".  Pod parsers must understand at least the entities
711           that define characters in the range 160-255 (Latin-1).  Pod
712           parsers, when faced with some unknown "E<identifier>" code,
713           shouldn't simply replace it with nullstring (by default, at least),
714           but may pass it through as a string consisting of the literal
715           characters E, less-than, identifier, greater-than.  Or Pod parsers
716           may offer the alternative option of processing such unknown
717           "E<identifier>" codes by firing an event especially for such codes,
718           or by adding a special node-type to the in-memory document tree.
719           Such "E<identifier>" may have special meaning to some processors,
720           or some processors may choose to add them to a special error
721           report.
722
723       ·   Pod parsers must also support the XHTML codes "E<quot>" for
724           character 34 (doublequote, "), "E<amp>" for character 38
725           (ampersand, &), and "E<apos>" for character 39 (apostrophe, ').
726
727       ·   Note that in all cases of "E<whatever>", whatever (whether an
728           htmlname, or a number in any base) must consist only of
729           alphanumeric characters -- that is, whatever must watch
730           "m/\A\w+\z/".  So "E< 0 1 2 3 >" is invalid, because it contains
731           spaces, which aren't alphanumeric characters.  This presumably does
732           not need special treatment by a Pod processor; " 0 1 2 3 " doesn't
733           look like a number in any base, so it would presumably be looked up
734           in the table of HTML-like names.  Since there isn't (and cannot be)
735           an HTML-like entity called " 0 1 2 3 ", this will be treated as an
736           error.  However, Pod processors may treat "E< 0 1 2 3 >" or
737           "E<e-acute>" as syntactically invalid, potentially earning a
738           different error message than the error message (or warning, or
739           event) generated by a merely unknown (but theoretically valid)
740           htmlname, as in "E<qacute>" [sic].  However, Pod parsers are not
741           required to make this distinction.
742
743       ·   Note that E<number> must not be interpreted as simply "codepoint
744           number in the current/native character set".  It always means only
745           "the character represented by codepoint number in Unicode."  (This
746           is identical to the semantics of &#number; in XML.)
747
748           This will likely require many formatters to have tables mapping
749           from treatable Unicode codepoints (such as the "\xE9" for the
750           e-acute character) to the escape sequences or codes necessary for
751           conveying such sequences in the target output format.  A converter
752           to *roff would, for example know that "\xE9" (whether conveyed
753           literally, or via a E<...> sequence) is to be conveyed as "e\\*'".
754           Similarly, a program rendering Pod in a Mac OS application window,
755           would presumably need to know that "\xE9" maps to codepoint 142 in
756           MacRoman encoding that (at time of writing) is native for Mac OS.
757           Such Unicode2whatever mappings are presumably already widely
758           available for common output formats.  (Such mappings may be
759           incomplete!  Implementers are not expected to bend over backwards
760           in an attempt to render Cherokee syllabics, Etruscan runes,
761           Byzantine musical symbols, or any of the other weird things that
762           Unicode can encode.)  And if a Pod document uses a character not
763           found in such a mapping, the formatter should consider it an
764           unrenderable character.
765
766       ·   If, surprisingly, the implementor of a Pod formatter can't find a
767           satisfactory pre-existing table mapping from Unicode characters to
768           escapes in the target format (e.g., a decent table of Unicode
769           characters to *roff escapes), it will be necessary to build such a
770           table.  If you are in this circumstance, you should begin with the
771           characters in the range 0x00A0 - 0x00FF, which is mostly the
772           heavily used accented characters.  Then proceed (as patience
773           permits and fastidiousness compels) through the characters that the
774           (X)HTML standards groups judged important enough to merit mnemonics
775           for.  These are declared in the (X)HTML specifications at the
776           www.W3.org site.  At time of writing (September 2001), the most
777           recent entity declaration files are:
778
779             http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
780             http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
781             http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent
782
783           Then you can progress through any remaining notable Unicode
784           characters in the range 0x2000-0x204D (consult the character tables
785           at www.unicode.org), and whatever else strikes your fancy.  For
786           example, in xhtml-symbol.ent, there is the entry:
787
788             <!ENTITY infin    "&#8734;"> <!-- infinity, U+221E ISOtech -->
789
790           While the mapping "infin" to the character "\x{221E}" will
791           (hopefully) have been already handled by the Pod parser, the
792           presence of the character in this file means that it's reasonably
793           important enough to include in a formatter's table that maps from
794           notable Unicode characters to the codes necessary for rendering
795           them.  So for a Unicode-to-*roff mapping, for example, this would
796           merit the entry:
797
798             "\x{221E}" => '\(in',
799
800           It is eagerly hoped that in the future, increasing numbers of
801           formats (and formatters) will support Unicode characters directly
802           (as (X)HTML does with "&infin;", "&#8734;", or "&#x221E;"),
803           reducing the need for idiosyncratic mappings of
804           Unicode-to-my_escapes.
805
806       ·   It is up to individual Pod formatter to display good judgement when
807           confronted with an unrenderable character (which is distinct from
808           an unknown E<thing> sequence that the parser couldn't resolve to
809           anything, renderable or not).  It is good practice to map Latin
810           letters with diacritics (like "E<eacute>"/"E<233>") to the
811           corresponding unaccented US-ASCII letters (like a simple character
812           101, "e"), but clearly this is often not feasible, and an
813           unrenderable character may be represented as "?", or the like.  In
814           attempting a sane fallback (as from E<233> to "e"), Pod formatters
815           may use the %Latin1Code_to_fallback table in Pod::Escapes, or
816           Text::Unidecode, if available.
817
818           For example, this Pod text:
819
820             magic is enabled if you set C<$Currency> to 'E<euro>'.
821
822           may be rendered as: "magic is enabled if you set $Currency to '?'"
823           or as "magic is enabled if you set $Currency to '[euro]'", or as
824           "magic is enabled if you set $Currency to '[x20AC]', etc.
825
826           A Pod formatter may also note, in a comment or warning, a list of
827           what unrenderable characters were encountered.
828
829       ·   E<...> may freely appear in any formatting code (other than in
830           another E<...> or in an Z<>).  That is, "X<The E<euro>1,000,000
831           Solution>" is valid, as is "L<The E<euro>1,000,000
832           Solution|Million::Euros>".
833
834       ·   Some Pod formatters output to formats that implement non-breaking
835           spaces as an individual character (which I'll call "NBSP"), and
836           others output to formats that implement non-breaking spaces just as
837           spaces wrapped in a "don't break this across lines" code.  Note
838           that at the level of Pod, both sorts of codes can occur: Pod can
839           contain a NBSP character (whether as a literal, or as a "E<160>" or
840           "E<nbsp>" code); and Pod can contain "S<foo I<bar> baz>" codes,
841           where "mere spaces" (character 32) in such codes are taken to
842           represent non-breaking spaces.  Pod parsers should consider
843           supporting the optional parsing of "S<foo I<bar> baz>" as if it
844           were "fooNBSPI<bar>NBSPbaz", and, going the other way, the optional
845           parsing of groups of words joined by NBSP's as if each group were
846           in a S<...> code, so that formatters may use the representation
847           that maps best to what the output format demands.
848
849       ·   Some processors may find that the "S<...>" code is easiest to
850           implement by replacing each space in the parse tree under the
851           content of the S, with an NBSP.  But note: the replacement should
852           apply not to spaces in all text, but only to spaces in printable
853           text.  (This distinction may or may not be evident in the
854           particular tree/event model implemented by the Pod parser.)  For
855           example, consider this unusual case:
856
857              S<L</Autoloaded Functions>>
858
859           This means that the space in the middle of the visible link text
860           must not be broken across lines.  In other words, it's the same as
861           this:
862
863              L<"AutoloadedE<160>Functions"/Autoloaded Functions>
864
865           However, a misapplied space-to-NBSP replacement could (wrongly)
866           produce something equivalent to this:
867
868              L<"AutoloadedE<160>Functions"/AutoloadedE<160>Functions>
869
870           ...which is almost definitely not going to work as a hyperlink
871           (assuming this formatter outputs a format supporting hypertext).
872
873           Formatters may choose to just not support the S format code,
874           especially in cases where the output format simply has no NBSP
875           character/code and no code for "don't break this stuff across
876           lines".
877
878       ·   Besides the NBSP character discussed above, implementors are
879           reminded of the existence of the other "special" character in
880           Latin-1, the "soft hyphen" character, also known as "discretionary
881           hyphen", i.e. "E<173>" = "E<0xAD>" = "E<shy>").  This character
882           expresses an optional hyphenation point.  That is, it normally
883           renders as nothing, but may render as a "-" if a formatter breaks
884           the word at that point.  Pod formatters should, as appropriate, do
885           one of the following:  1) render this with a code with the same
886           meaning (e.g., "\-" in RTF), 2) pass it through in the expectation
887           that the formatter understands this character as such, or 3) delete
888           it.
889
890           For example:
891
892             sigE<shy>action
893             manuE<shy>script
894             JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
895
896           These signal to a formatter that if it is to hyphenate "sigaction"
897           or "manuscript", then it should be done as "sig-[linebreak]action"
898           or "manu-[linebreak]script" (and if it doesn't hyphenate it, then
899           the "E<shy>" doesn't show up at all).  And if it is to hyphenate
900           "Jarkko" and/or "Hietaniemi", it can do so only at the points where
901           there is a "E<shy>" code.
902
903           In practice, it is anticipated that this character will not be used
904           often, but formatters should either support it, or delete it.
905
906       ·   If you think that you want to add a new command to Pod (like, say,
907           a "=biblio" command), consider whether you could get the same
908           effect with a for or begin/end sequence: "=for biblio ..." or
909           "=begin biblio" ... "=end biblio".  Pod processors that don't
910           understand "=for biblio", etc, will simply ignore it, whereas they
911           may complain loudly if they see "=biblio".
912
913       ·   Throughout this document, "Pod" has been the preferred spelling for
914           the name of the documentation format.  One may also use "POD" or
915           "pod".  For the documentation that is (typically) in the Pod
916           format, you may use "pod", or "Pod", or "POD".  Understanding these
917           distinctions is useful; but obsessing over how to spell them,
918           usually is not.
919

About L<...> Codes

921       As you can tell from a glance at perlpod, the L<...> code is the most
922       complex of the Pod formatting codes.  The points below will hopefully
923       clarify what it means and how processors should deal with it.
924
925       ·   In parsing an L<...> code, Pod parsers must distinguish at least
926           four attributes:
927
928           First:
929               The link-text.  If there is none, this must be undef.  (E.g.,
930               in "L<Perl Functions|perlfunc>", the link-text is "Perl
931               Functions".  In "L<Time::HiRes>" and even "L<|Time::HiRes>",
932               there is no link text.  Note that link text may contain
933               formatting.)
934
935           Second:
936               The possibly inferred link-text; i.e., if there was no real
937               link text, then this is the text that we'll infer in its place.
938               (E.g., for "L<Getopt::Std>", the inferred link text is
939               "Getopt::Std".)
940
941           Third:
942               The name or URL, or undef if none.  (E.g., in "L<Perl
943               Functions|perlfunc>", the name (also sometimes called the page)
944               is "perlfunc".  In "L</CAVEATS>", the name is undef.)
945
946           Fourth:
947               The section (AKA "item" in older perlpods), or undef if none.
948               E.g., in "L<Getopt::Std/DESCRIPTION>", "DESCRIPTION" is the
949               section.  (Note that this is not the same as a manpage section
950               like the "5" in "man 5 crontab".  "Section Foo" in the Pod
951               sense means the part of the text that's introduced by the
952               heading or item whose text is "Foo".)
953
954           Pod parsers may also note additional attributes including:
955
956           Fifth:
957               A flag for whether item 3 (if present) is a URL (like
958               "http://lists.perl.org" is), in which case there should be no
959               section attribute; a Pod name (like "perldoc" and "Getopt::Std"
960               are); or possibly a man page name (like "crontab(5)" is).
961
962           Sixth:
963               The raw original L<...> content, before text is split on "|",
964               "/", etc, and before E<...> codes are expanded.
965
966           (The above were numbered only for concise reference below.  It is
967           not a requirement that these be passed as an actual list or array.)
968
969           For example:
970
971             L<Foo::Bar>
972               =>  undef,                          # link text
973                   "Foo::Bar",                     # possibly inferred link text
974                   "Foo::Bar",                     # name
975                   undef,                          # section
976                   'pod',                          # what sort of link
977                   "Foo::Bar"                      # original content
978
979             L<Perlport's section on NL's|perlport/Newlines>
980               =>  "Perlport's section on NL's",   # link text
981                   "Perlport's section on NL's",   # possibly inferred link text
982                   "perlport",                     # name
983                   "Newlines",                     # section
984                   'pod',                          # what sort of link
985                   "Perlport's section on NL's|perlport/Newlines" # orig. content
986
987             L<perlport/Newlines>
988               =>  undef,                          # link text
989                   '"Newlines" in perlport',       # possibly inferred link text
990                   "perlport",                     # name
991                   "Newlines",                     # section
992                   'pod',                          # what sort of link
993                   "perlport/Newlines"             # original content
994
995             L<crontab(5)/"DESCRIPTION">
996               =>  undef,                          # link text
997                   '"DESCRIPTION" in crontab(5)',  # possibly inferred link text
998                   "crontab(5)",                   # name
999                   "DESCRIPTION",                  # section
1000                   'man',                          # what sort of link
1001                   'crontab(5)/"DESCRIPTION"'      # original content
1002
1003             L</Object Attributes>
1004               =>  undef,                          # link text
1005                   '"Object Attributes"',          # possibly inferred link text
1006                   undef,                          # name
1007                   "Object Attributes",            # section
1008                   'pod',                          # what sort of link
1009                   "/Object Attributes"            # original content
1010
1011             L<http://www.perl.org/>
1012               =>  undef,                          # link text
1013                   "http://www.perl.org/",         # possibly inferred link text
1014                   "http://www.perl.org/",         # name
1015                   undef,                          # section
1016                   'url',                          # what sort of link
1017                   "http://www.perl.org/"          # original content
1018
1019             L<Perl.org|http://www.perl.org/>
1020               =>  "Perl.org",                     # link text
1021                   "http://www.perl.org/",         # possibly inferred link text
1022                   "http://www.perl.org/",         # name
1023                   undef,                          # section
1024                   'url',                          # what sort of link
1025                   "Perl.org|http://www.perl.org/" # original content
1026
1027           Note that you can distinguish URL-links from anything else by the
1028           fact that they match "m/\A\w+:[^:\s]\S*\z/".  So
1029           "L<http://www.perl.com>" is a URL, but "L<HTTP::Response>" isn't.
1030
1031       ·   In case of L<...> codes with no "text|" part in them, older
1032           formatters have exhibited great variation in actually displaying
1033           the link or cross reference.  For example, L<crontab(5)> would
1034           render as "the crontab(5) manpage", or "in the crontab(5) manpage"
1035           or just "crontab(5)".
1036
1037           Pod processors must now treat "text|"-less links as follows:
1038
1039             L<name>         =>  L<name|name>
1040             L</section>     =>  L<"section"|/section>
1041             L<name/section> =>  L<"section" in name|name/section>
1042
1043       ·   Note that section names might contain markup.  I.e., if a section
1044           starts with:
1045
1046             =head2 About the C<-M> Operator
1047
1048           or with:
1049
1050             =item About the C<-M> Operator
1051
1052           then a link to it would look like this:
1053
1054             L<somedoc/About the C<-M> Operator>
1055
1056           Formatters may choose to ignore the markup for purposes of
1057           resolving the link and use only the renderable characters in the
1058           section name, as in:
1059
1060             <h1><a name="About_the_-M_Operator">About the <code>-M</code>
1061             Operator</h1>
1062
1063             ...
1064
1065             <a href="somedoc#About_the_-M_Operator">About the <code>-M</code>
1066             Operator" in somedoc</a>
1067
1068       ·   Previous versions of perlpod distinguished "L<name/"section">"
1069           links from "L<name/item>" links (and their targets).  These have
1070           been merged syntactically and semantically in the current
1071           specification, and section can refer either to a "=headn Heading
1072           Content" command or to a "=item Item Content" command.  This
1073           specification does not specify what behavior should be in the case
1074           of a given document having several things all seeming to produce
1075           the same section identifier (e.g., in HTML, several things all
1076           producing the same anchorname in <a name="anchorname">...</a>
1077           elements).  Where Pod processors can control this behavior, they
1078           should use the first such anchor.  That is, "L<Foo/Bar>" refers to
1079           the first "Bar" section in Foo.
1080
1081           But for some processors/formats this cannot be easily controlled;
1082           as with the HTML example, the behavior of multiple ambiguous <a
1083           name="anchorname">...</a> is most easily just left up to browsers
1084           to decide.
1085
1086       ·   In a "L<text|...>" code, text may contain formatting codes for
1087           formatting or for E<...> escapes, as in:
1088
1089             L<B<ummE<234>stuff>|...>
1090
1091           For "L<...>" codes without a "name|" part, only "E<...>" and "Z<>"
1092           codes may occur.  That is, authors should not use
1093           ""L<B<Foo::Bar>>"".
1094
1095           Note, however, that formatting codes and Z<>'s can occur in any and
1096           all parts of an L<...> (i.e., in name, section, text, and url).
1097
1098           Authors must not nest L<...> codes.  For example, "L<The
1099           L<Foo::Bar> man page>" should be treated as an error.
1100
1101       ·   Note that Pod authors may use formatting codes inside the "text"
1102           part of "L<text|name>" (and so on for L<text|/"sec">).
1103
1104           In other words, this is valid:
1105
1106             Go read L<the docs on C<$.>|perlvar/"$.">
1107
1108           Some output formats that do allow rendering "L<...>" codes as
1109           hypertext, might not allow the link-text to be formatted; in that
1110           case, formatters will have to just ignore that formatting.
1111
1112       ·   At time of writing, "L<name>" values are of two types: either the
1113           name of a Pod page like "L<Foo::Bar>" (which might be a real Perl
1114           module or program in an @INC / PATH directory, or a .pod file in
1115           those places); or the name of a Unix man page, like
1116           "L<crontab(5)>".  In theory, "L<chmod>" in ambiguous between a Pod
1117           page called "chmod", or the Unix man page "chmod" (in whatever man-
1118           section).  However, the presence of a string in parens, as in
1119           "crontab(5)", is sufficient to signal that what is being discussed
1120           is not a Pod page, and so is presumably a Unix man page.  The
1121           distinction is of no importance to many Pod processors, but some
1122           processors that render to hypertext formats may need to distinguish
1123           them in order to know how to render a given "L<foo>" code.
1124
1125       ·   Previous versions of perlpod allowed for a "L<section>" syntax (as
1126           in "L<Object Attributes>"), which was not easily distinguishable
1127           from "L<name>" syntax and for "L<"section">" which was only
1128           slightly less ambiguous.  This syntax is no longer in the
1129           specification, and has been replaced by the "L</section>" syntax
1130           (where the slash was formerly optional).  Pod parsers should
1131           tolerate the "L<"section">" syntax, for a while at least.  The
1132           suggested heuristic for distinguishing "L<section>" from "L<name>"
1133           is that if it contains any whitespace, it's a section.  Pod
1134           processors should warn about this being deprecated syntax.
1135

About =over...=back Regions

1137       "=over"..."=back" regions are used for various kinds of list-like
1138       structures.  (I use the term "region" here simply as a collective term
1139       for everything from the "=over" to the matching "=back".)
1140
1141       ·   The non-zero numeric indentlevel in "=over indentlevel" ...
1142           "=back" is used for giving the formatter a clue as to how many
1143           "spaces" (ems, or roughly equivalent units) it should tab over,
1144           although many formatters will have to convert this to an absolute
1145           measurement that may not exactly match with the size of spaces (or
1146           M's) in the document's base font.  Other formatters may have to
1147           completely ignore the number.  The lack of any explicit indentlevel
1148           parameter is equivalent to an indentlevel value of 4.  Pod
1149           processors may complain if indentlevel is present but is not a
1150           positive number matching "m/\A(\d*\.)?\d+\z/".
1151
1152       ·   Authors of Pod formatters are reminded that "=over" ... "=back" may
1153           map to several different constructs in your output format.  For
1154           example, in converting Pod to (X)HTML, it can map to any of
1155           <ul>...</ul>, <ol>...</ol>, <dl>...</dl>, or
1156           <blockquote>...</blockquote>.  Similarly, "=item" can map to <li>
1157           or <dt>.
1158
1159       ·   Each "=over" ... "=back" region should be one of the following:
1160
1161           ·   An "=over" ... "=back" region containing only "=item *"
1162               commands, each followed by some number of ordinary/verbatim
1163               paragraphs, other nested "=over" ... "=back" regions, "=for..."
1164               paragraphs, and "=begin"..."=end" regions.
1165
1166               (Pod processors must tolerate a bare "=item" as if it were
1167               "=item *".)  Whether "*" is rendered as a literal asterisk, an
1168               "o", or as some kind of real bullet character, is left up to
1169               the Pod formatter, and may depend on the level of nesting.
1170
1171           ·   An "=over" ... "=back" region containing only
1172               "m/\A=item\s+\d+\.?\s*\z/" paragraphs, each one (or each group
1173               of them) followed by some number of ordinary/verbatim
1174               paragraphs, other nested "=over" ... "=back" regions, "=for..."
1175               paragraphs, and/or "=begin"..."=end" codes.  Note that the
1176               numbers must start at 1 in each section, and must proceed in
1177               order and without skipping numbers.
1178
1179               (Pod processors must tolerate lines like "=item 1" as if they
1180               were "=item 1.", with the period.)
1181
1182           ·   An "=over" ... "=back" region containing only "=item [text]"
1183               commands, each one (or each group of them) followed by some
1184               number of ordinary/verbatim paragraphs, other nested "=over"
1185               ... "=back" regions, or "=for..." paragraphs, and
1186               "=begin"..."=end" regions.
1187
1188               The "=item [text]" paragraph should not match
1189               "m/\A=item\s+\d+\.?\s*\z/" or "m/\A=item\s+\*\s*\z/", nor
1190               should it match just "m/\A=item\s*\z/".
1191
1192           ·   An "=over" ... "=back" region containing no "=item" paragraphs
1193               at all, and containing only some number of ordinary/verbatim
1194               paragraphs, and possibly also some nested "=over" ... "=back"
1195               regions, "=for..." paragraphs, and "=begin"..."=end" regions.
1196               Such an itemless "=over" ... "=back" region in Pod is
1197               equivalent in meaning to a "<blockquote>...</blockquote>"
1198               element in HTML.
1199
1200           Note that with all the above cases, you can determine which type of
1201           "=over" ... "=back" you have, by examining the first (non-"=cut",
1202           non-"=pod") Pod paragraph after the "=over" command.
1203
1204       ·   Pod formatters must tolerate arbitrarily large amounts of text in
1205           the "=item text..." paragraph.  In practice, most such paragraphs
1206           are short, as in:
1207
1208             =item For cutting off our trade with all parts of the world
1209
1210           But they may be arbitrarily long:
1211
1212             =item For transporting us beyond seas to be tried for pretended
1213             offenses
1214
1215             =item He is at this time transporting large armies of foreign
1216             mercenaries to complete the works of death, desolation and
1217             tyranny, already begun with circumstances of cruelty and perfidy
1218             scarcely paralleled in the most barbarous ages, and totally
1219             unworthy the head of a civilized nation.
1220
1221       ·   Pod processors should tolerate "=item *" / "=item number" commands
1222           with no accompanying paragraph.  The middle item is an example:
1223
1224             =over
1225
1226             =item 1
1227
1228             Pick up dry cleaning.
1229
1230             =item 2
1231
1232             =item 3
1233
1234             Stop by the store.  Get Abba Zabas, Stoli, and cheap lawn chairs.
1235
1236             =back
1237
1238       ·   No "=over" ... "=back" region can contain headings.  Processors may
1239           treat such a heading as an error.
1240
1241       ·   Note that an "=over" ... "=back" region should have some content.
1242           That is, authors should not have an empty region like this:
1243
1244             =over
1245
1246             =back
1247
1248           Pod processors seeing such a contentless "=over" ... "=back"
1249           region, may ignore it, or may report it as an error.
1250
1251       ·   Processors must tolerate an "=over" list that goes off the end of
1252           the document (i.e., which has no matching "=back"), but they may
1253           warn about such a list.
1254
1255       ·   Authors of Pod formatters should note that this construct:
1256
1257             =item Neque
1258
1259             =item Porro
1260
1261             =item Quisquam Est
1262
1263             Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1264             velit, sed quia non numquam eius modi tempora incidunt ut
1265             labore et dolore magnam aliquam quaerat voluptatem.
1266
1267             =item Ut Enim
1268
1269           is semantically ambiguous, in a way that makes formatting decisions
1270           a bit difficult.  On the one hand, it could be mention of an item
1271           "Neque", mention of another item "Porro", and mention of another
1272           item "Quisquam Est", with just the last one requiring the
1273           explanatory paragraph "Qui dolorem ipsum quia dolor..."; and then
1274           an item "Ut Enim".  In that case, you'd want to format it like so:
1275
1276             Neque
1277
1278             Porro
1279
1280             Quisquam Est
1281               Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1282               velit, sed quia non numquam eius modi tempora incidunt ut
1283               labore et dolore magnam aliquam quaerat voluptatem.
1284
1285             Ut Enim
1286
1287           But it could equally well be a discussion of three (related or
1288           equivalent) items, "Neque", "Porro", and "Quisquam Est", followed
1289           by a paragraph explaining them all, and then a new item "Ut Enim".
1290           In that case, you'd probably want to format it like so:
1291
1292             Neque
1293             Porro
1294             Quisquam Est
1295               Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1296               velit, sed quia non numquam eius modi tempora incidunt ut
1297               labore et dolore magnam aliquam quaerat voluptatem.
1298
1299             Ut Enim
1300
1301           But (for the foreseeable future), Pod does not provide any way for
1302           Pod authors to distinguish which grouping is meant by the above
1303           "=item"-cluster structure.  So formatters should format it like so:
1304
1305             Neque
1306
1307             Porro
1308
1309             Quisquam Est
1310
1311               Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1312               velit, sed quia non numquam eius modi tempora incidunt ut
1313               labore et dolore magnam aliquam quaerat voluptatem.
1314
1315             Ut Enim
1316
1317           That is, there should be (at least roughly) equal spacing between
1318           items as between paragraphs (although that spacing may well be less
1319           than the full height of a line of text).  This leaves it to the
1320           reader to use (con)textual cues to figure out whether the "Qui
1321           dolorem ipsum..." paragraph applies to the "Quisquam Est" item or
1322           to all three items "Neque", "Porro", and "Quisquam Est".  While not
1323           an ideal situation, this is preferable to providing formatting cues
1324           that may be actually contrary to the author's intent.
1325

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

1327       Data paragraphs are typically used for inlining non-Pod data that is to
1328       be used (typically passed through) when rendering the document to a
1329       specific format:
1330
1331         =begin rtf
1332
1333         \par{\pard\qr\sa4500{\i Printed\~\chdate\~\chtime}\par}
1334
1335         =end rtf
1336
1337       The exact same effect could, incidentally, be achieved with a single
1338       "=for" paragraph:
1339
1340         =for rtf \par{\pard\qr\sa4500{\i Printed\~\chdate\~\chtime}\par}
1341
1342       (Although that is not formally a data paragraph, it has the same
1343       meaning as one, and Pod parsers may parse it as one.)
1344
1345       Another example of a data paragraph:
1346
1347         =begin html
1348
1349         I like <em>PIE</em>!
1350
1351         <hr>Especially pecan pie!
1352
1353         =end html
1354
1355       If these were ordinary paragraphs, the Pod parser would try to expand
1356       the "E</em>" (in the first paragraph) as a formatting code, just like
1357       "E<lt>" or "E<eacute>".  But since this is in a "=begin
1358       identifier"..."=end identifier" region and the identifier "html"
1359       doesn't begin have a ":" prefix, the contents of this region are stored
1360       as data paragraphs, instead of being processed as ordinary paragraphs
1361       (or if they began with a spaces and/or tabs, as verbatim paragraphs).
1362
1363       As a further example: At time of writing, no "biblio" identifier is
1364       supported, but suppose some processor were written to recognize it as a
1365       way of (say) denoting a bibliographic reference (necessarily containing
1366       formatting codes in ordinary paragraphs).  The fact that "biblio"
1367       paragraphs were meant for ordinary processing would be indicated by
1368       prefacing each "biblio" identifier with a colon:
1369
1370         =begin :biblio
1371
1372         Wirth, Niklaus.  1976.  I<Algorithms + Data Structures =
1373         Programs.>  Prentice-Hall, Englewood Cliffs, NJ.
1374
1375         =end :biblio
1376
1377       This would signal to the parser that paragraphs in this begin...end
1378       region are subject to normal handling as ordinary/verbatim paragraphs
1379       (while still tagged as meant only for processors that understand the
1380       "biblio" identifier).  The same effect could be had with:
1381
1382         =for :biblio
1383         Wirth, Niklaus.  1976.  I<Algorithms + Data Structures =
1384         Programs.>  Prentice-Hall, Englewood Cliffs, NJ.
1385
1386       The ":" on these identifiers means simply "process this stuff normally,
1387       even though the result will be for some special target".  I suggest
1388       that parser APIs report "biblio" as the target identifier, but also
1389       report that it had a ":" prefix.  (And similarly, with the above
1390       "html", report "html" as the target identifier, and note the lack of a
1391       ":" prefix.)
1392
1393       Note that a "=begin identifier"..."=end identifier" region where
1394       identifier begins with a colon, can contain commands.  For example:
1395
1396         =begin :biblio
1397
1398         Wirth's classic is available in several editions, including:
1399
1400         =for comment
1401          hm, check abebooks.com for how much used copies cost.
1402
1403         =over
1404
1405         =item
1406
1407         Wirth, Niklaus.  1975.  I<Algorithmen und Datenstrukturen.>
1408         Teubner, Stuttgart.  [Yes, it's in German.]
1409
1410         =item
1411
1412         Wirth, Niklaus.  1976.  I<Algorithms + Data Structures =
1413         Programs.>  Prentice-Hall, Englewood Cliffs, NJ.
1414
1415         =back
1416
1417         =end :biblio
1418
1419       Note, however, a "=begin identifier"..."=end identifier" region where
1420       identifier does not begin with a colon, should not directly contain
1421       "=head1" ... "=head4" commands, nor "=over", nor "=back", nor "=item".
1422       For example, this may be considered invalid:
1423
1424         =begin somedata
1425
1426         This is a data paragraph.
1427
1428         =head1 Don't do this!
1429
1430         This is a data paragraph too.
1431
1432         =end somedata
1433
1434       A Pod processor may signal that the above (specifically the "=head1"
1435       paragraph) is an error.  Note, however, that the following should not
1436       be treated as an error:
1437
1438         =begin somedata
1439
1440         This is a data paragraph.
1441
1442         =cut
1443
1444         # Yup, this isn't Pod anymore.
1445         sub excl { (rand() > .5) ? "hoo!" : "hah!" }
1446
1447         =pod
1448
1449         This is a data paragraph too.
1450
1451         =end somedata
1452
1453       And this too is valid:
1454
1455         =begin someformat
1456
1457         This is a data paragraph.
1458
1459           And this is a data paragraph.
1460
1461         =begin someotherformat
1462
1463         This is a data paragraph too.
1464
1465           And this is a data paragraph too.
1466
1467         =begin :yetanotherformat
1468
1469         =head2 This is a command paragraph!
1470
1471         This is an ordinary paragraph!
1472
1473           And this is a verbatim paragraph!
1474
1475         =end :yetanotherformat
1476
1477         =end someotherformat
1478
1479         Another data paragraph!
1480
1481         =end someformat
1482
1483       The contents of the above "=begin :yetanotherformat" ...  "=end
1484       :yetanotherformat" region aren't data paragraphs, because the
1485       immediately containing region's identifier (":yetanotherformat") begins
1486       with a colon.  In practice, most regions that contain data paragraphs
1487       will contain only data paragraphs; however, the above nesting is
1488       syntactically valid as Pod, even if it is rare.  However, the handlers
1489       for some formats, like "html", will accept only data paragraphs, not
1490       nested regions; and they may complain if they see (targeted for them)
1491       nested regions, or commands, other than "=end", "=pod", and "=cut".
1492
1493       Also consider this valid structure:
1494
1495         =begin :biblio
1496
1497         Wirth's classic is available in several editions, including:
1498
1499         =over
1500
1501         =item
1502
1503         Wirth, Niklaus.  1975.  I<Algorithmen und Datenstrukturen.>
1504         Teubner, Stuttgart.  [Yes, it's in German.]
1505
1506         =item
1507
1508         Wirth, Niklaus.  1976.  I<Algorithms + Data Structures =
1509         Programs.>  Prentice-Hall, Englewood Cliffs, NJ.
1510
1511         =back
1512
1513         Buy buy buy!
1514
1515         =begin html
1516
1517         <img src='wirth_spokesmodeling_book.png'>
1518
1519         <hr>
1520
1521         =end html
1522
1523         Now now now!
1524
1525         =end :biblio
1526
1527       There, the "=begin html"..."=end html" region is nested inside the
1528       larger "=begin :biblio"..."=end :biblio" region.  Note that the content
1529       of the "=begin html"..."=end html" region is data paragraph(s), because
1530       the immediately containing region's identifier ("html") doesn't begin
1531       with a colon.
1532
1533       Pod parsers, when processing a series of data paragraphs one after
1534       another (within a single region), should consider them to be one large
1535       data paragraph that happens to contain blank lines.  So the content of
1536       the above "=begin html"..."=end html" may be stored as two data
1537       paragraphs (one consisting of "<img
1538       src='wirth_spokesmodeling_book.png'>\n" and another consisting of
1539       "<hr>\n"), but should be stored as a single data paragraph (consisting
1540       of "<img src='wirth_spokesmodeling_book.png'>\n\n<hr>\n").
1541
1542       Pod processors should tolerate empty "=begin something"..."=end
1543       something" regions, empty "=begin :something"..."=end :something"
1544       regions, and contentless "=for something" and "=for :something"
1545       paragraphs.  I.e., these should be tolerated:
1546
1547         =for html
1548
1549         =begin html
1550
1551         =end html
1552
1553         =begin :biblio
1554
1555         =end :biblio
1556
1557       Incidentally, note that there's no easy way to express a data paragraph
1558       starting with something that looks like a command.  Consider:
1559
1560         =begin stuff
1561
1562         =shazbot
1563
1564         =end stuff
1565
1566       There, "=shazbot" will be parsed as a Pod command "shazbot", not as a
1567       data paragraph "=shazbot\n".  However, you can express a data paragraph
1568       consisting of "=shazbot\n" using this code:
1569
1570         =for stuff =shazbot
1571
1572       The situation where this is necessary, is presumably quite rare.
1573
1574       Note that =end commands must match the currently open =begin command.
1575       That is, they must properly nest.  For example, this is valid:
1576
1577         =begin outer
1578
1579         X
1580
1581         =begin inner
1582
1583         Y
1584
1585         =end inner
1586
1587         Z
1588
1589         =end outer
1590
1591       while this is invalid:
1592
1593         =begin outer
1594
1595         X
1596
1597         =begin inner
1598
1599         Y
1600
1601         =end outer
1602
1603         Z
1604
1605         =end inner
1606
1607       This latter is improper because when the "=end outer" command is seen,
1608       the currently open region has the formatname "inner", not "outer".  (It
1609       just happens that "outer" is the format name of a higher-up region.)
1610       This is an error.  Processors must by default report this as an error,
1611       and may halt processing the document containing that error.  A
1612       corollary of this is that regions cannot "overlap". That is, the latter
1613       block above does not represent a region called "outer" which contains X
1614       and Y, overlapping a region called "inner" which contains Y and Z.  But
1615       because it is invalid (as all apparently overlapping regions would be),
1616       it doesn't represent that, or anything at all.
1617
1618       Similarly, this is invalid:
1619
1620         =begin thing
1621
1622         =end hting
1623
1624       This is an error because the region is opened by "thing", and the
1625       "=end" tries to close "hting" [sic].
1626
1627       This is also invalid:
1628
1629         =begin thing
1630
1631         =end
1632
1633       This is invalid because every "=end" command must have a formatname
1634       parameter.
1635

SEE ALSO

1637       perlpod, "PODs: Embedded Documentation" in perlsyn, podchecker
1638

AUTHOR

1640       Sean M. Burke
1641
1642
1643
1644perl v5.16.3                      2013-03-04                    PERLPODSPEC(1)
Impressum