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
32       can 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:?[aXXaaXXzAaXXZ0aXX9_]+\z/".  Everything following whitespace
256           after the formatname is a parameter that may be used by the
257           formatter when dealing with this region.  This parameter must not
258           be repeated in the "=end" paragraph.  Implementors should
259           anticipate future expansion in the semantics and syntax of the
260           first parameter to "=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       In parsing Pod, a notably tricky part is the correct parsing of
364       (potentially nested!) formatting codes.  Implementors should consult
365       the code in the "parse_text" routine in Pod::Parser as an example of a
366       correct implementation.
367
368       "I<text>" -- italic text
369           See the brief discussion in "Formatting Codes" in perlpod.
370
371       "B<text>" -- bold text
372           See the brief discussion in "Formatting Codes" in perlpod.
373
374       "C<code>" -- code text
375           See the brief discussion in "Formatting Codes" in perlpod.
376
377       "F<filename>" -- style for filenames
378           See the brief discussion in "Formatting Codes" in perlpod.
379
380       "X<topic name>" -- an index entry
381           See the brief discussion in "Formatting Codes" in perlpod.
382
383           This code is unusual in that most formatters completely discard
384           this code and its content.  Other formatters will render it with
385           invisible codes that can be used in building an index of the
386           current document.
387
388       "Z<>" -- a null (zero-effect) formatting code
389           Discussed briefly in "Formatting Codes" in perlpod.
390
391           This code is unusual is that it should have no content.  That is, a
392           processor may complain if it sees "Z<potatoes>".  Whether or not it
393           complains, the potatoes text should ignored.
394
395       "L<name>" -- a hyperlink
396           The complicated syntaxes of this code are discussed at length in
397           "Formatting Codes" in perlpod, and implementation details are
398           discussed below, in "About L<...> Codes".  Parsing the contents of
399           L<content> is tricky.  Notably, the content has to be checked for
400           whether it looks like a URL, or whether it has to be split on
401           literal "|" and/or "/" (in the right order!), and so on, before
402           E<...> codes are resolved.
403
404       "E<escape>" -- a character escape
405           See "Formatting Codes" in perlpod, and several points in "Notes on
406           Implementing Pod Processors".
407
408       "S<text>" -- text contains non-breaking spaces
409           This formatting code is syntactically simple, but semantically
410           complex.  What it means is that each space in the printable content
411           of this code signifies a non-breaking space.
412
413           Consider:
414
415               C<$x ? $y    :  $z>
416
417               S<C<$x ? $y     :  $z>>
418
419           Both signify the monospace (c[ode] style) text consisting of "$x",
420           one space, "?", one space, ":", one space, "$z".  The difference is
421           that in the latter, with the S code, those spaces are not "normal"
422           spaces, but instead are non-breaking spaces.
423
424       If a Pod processor sees any formatting code other than the ones listed
425       above (as in "N<...>", or "Q<...>", etc.), that processor must by
426       default treat this as an error.  A Pod parser may allow a way for
427       particular applications to add to the above list of known formatting
428       codes; a Pod parser might even allow a way to stipulate, for each
429       additional command, whether it requires some form of special
430       processing, as L<...> does.
431
432       Future versions of this specification may add additional formatting
433       codes.
434
435       Historical note:  A few older Pod processors would not see a ">" as
436       closing a "C<" code, if the ">" was immediately preceded by a "-".
437       This was so that this:
438
439           C<$foo->bar>
440
441       would parse as equivalent to this:
442
443           C<$foo-E<gt>bar>
444
445       instead of as equivalent to a "C" formatting code containing only
446       "$foo-", and then a "bar>" outside the "C" formatting code.  This
447       problem has since been solved by the addition of syntaxes like this:
448
449           C<< $foo->bar >>
450
451       Compliant parsers must not treat "->" as special.
452
453       Formatting codes absolutely cannot span paragraphs.  If a code is
454       opened in one paragraph, and no closing code is found by the end of
455       that paragraph, the Pod parser must close that formatting code, and
456       should complain (as in "Unterminated I code in the paragraph starting
457       at line 123: 'Time objects are not...'").  So these two paragraphs:
458
459         I<I told you not to do this!
460
461         Don't make me say it again!>
462
463       ...must not be parsed as two paragraphs in italics (with the I code
464       starting in one paragraph and starting in another.)  Instead, the first
465       paragraph should generate a warning, but that aside, the above code
466       must parse as if it were:
467
468         I<I told you not to do this!>
469
470         Don't make me say it again!E<gt>
471
472       (In SGMLish jargon, all Pod commands are like block-level elements,
473       whereas all Pod formatting codes are like inline-level elements.)
474

Notes on Implementing Pod Processors

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

About L<...> Codes

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

About =over...=back Regions

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

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

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

SEE ALSO

1631       perlpod, "PODs: Embedded Documentation" in perlsyn, podchecker
1632

AUTHOR

1634       Sean M. Burke
1635
1636
1637
1638perl v5.10.1                      2017-03-22                    PERLPODSPEC(1)
Impressum