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

About L<...> Codes

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

About =over...=back Regions

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

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

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

SEE ALSO

1649       perlpod, "PODs: Embedded Documentation" in perlsyn, podchecker
1650

AUTHOR

1652       Sean M. Burke
1653
1654
1655
1656perl v5.28.2                      2018-11-01                    PERLPODSPEC(1)
Impressum