1PERLPODSPEC(1) Perl Programmers Reference Guide PERLPODSPEC(1)
2
3
4
6 perlpodspec - Plain Old Documentation: format specification and notes
7
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
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 Note that a parser is not expected to distinguish between something
74 that looks like pod, but is in a quoted string, such as a here
75 document.
76
77 Within a Pod block, there are Pod paragraphs. A Pod paragraph consists
78 of non-blank lines of text, separated by one or more blank lines.
79
80 For purposes of Pod processing, there are four types of paragraphs in a
81 Pod block:
82
83 • A command paragraph (also called a "directive"). The first line of
84 this paragraph must match "m/\A=[a-zA-Z]/". Command paragraphs are
85 typically one line, as in:
86
87 =head1 NOTES
88
89 =item *
90
91 But they may span several (non-blank) lines:
92
93 =for comment
94 Hm, I wonder what it would look like if
95 you tried to write a BNF for Pod from this.
96
97 =head3 Dr. Strangelove, or: How I Learned to
98 Stop Worrying and Love the Bomb
99
100 Some command paragraphs allow formatting codes in their content
101 (i.e., after the part that matches "m/\A=[a-zA-Z]\S*\s*/"), as in:
102
103 =head1 Did You Remember to C<use strict;>?
104
105 In other words, the Pod processing handler for "head1" will apply
106 the same processing to "Did You Remember to C<use strict;>?" that
107 it would to an ordinary paragraph (i.e., formatting codes like
108 "C<...>") are parsed and presumably formatted appropriately, and
109 whitespace in the form of literal spaces and/or tabs is not
110 significant.
111
112 • A verbatim paragraph. The first line of this paragraph must be a
113 literal space or tab, and this paragraph must not be inside a
114 "=begin identifier", ... "=end identifier" sequence unless
115 "identifier" begins with a colon (":"). That is, if a paragraph
116 starts with a literal space or tab, but is inside a "=begin
117 identifier", ... "=end identifier" region, then it's a data
118 paragraph, unless "identifier" begins with a colon.
119
120 Whitespace is significant in verbatim paragraphs (although, in
121 processing, tabs are probably expanded).
122
123 • An ordinary paragraph. A paragraph is an ordinary paragraph if its
124 first line matches neither "m/\A=[a-zA-Z]/" nor "m/\A[ \t]/", and
125 if it's not inside a "=begin identifier", ... "=end identifier"
126 sequence unless "identifier" begins with a colon (":").
127
128 • A data paragraph. This is a paragraph that is inside a "=begin
129 identifier" ... "=end identifier" sequence where "identifier" does
130 not begin with a literal colon (":"). In some sense, a data
131 paragraph is not part of Pod at all (i.e., effectively it's "out-
132 of-band"), since it's not subject to most kinds of Pod parsing; but
133 it is specified here, since Pod parsers need to be able to call an
134 event for it, or store it in some form in a parse tree, or at least
135 just parse around it.
136
137 For example: consider the following paragraphs:
138
139 # <- that's the 0th column
140
141 =head1 Foo
142
143 Stuff
144
145 $foo->bar
146
147 =cut
148
149 Here, "=head1 Foo" and "=cut" are command paragraphs because the first
150 line of each matches "m/\A=[a-zA-Z]/". "[space][space]$foo->bar" is a
151 verbatim paragraph, because its first line starts with a literal
152 whitespace character (and there's no "=begin"..."=end" region around).
153
154 The "=begin identifier" ... "=end identifier" commands stop paragraphs
155 that they surround from being parsed as ordinary or verbatim
156 paragraphs, if identifier doesn't begin with a colon. This is
157 discussed in detail in the section "About Data Paragraphs and
158 "=begin/=end" Regions".
159
161 This section is intended to supplement and clarify the discussion in
162 "Command Paragraph" in perlpod. These are the currently recognized Pod
163 commands:
164
165 "=head1", "=head2", "=head3", "=head4"
166 This command indicates that the text in the remainder of the
167 paragraph is a heading. That text may contain formatting codes.
168 Examples:
169
170 =head1 Object Attributes
171
172 =head3 What B<Not> to Do!
173
174 "=pod"
175 This command indicates that this paragraph begins a Pod block. (If
176 we are already in the middle of a Pod block, this command has no
177 effect at all.) If there is any text in this command paragraph
178 after "=pod", it must be ignored. Examples:
179
180 =pod
181
182 This is a plain Pod paragraph.
183
184 =pod This text is ignored.
185
186 "=cut"
187 This command indicates that this line is the end of this previously
188 started Pod block. If there is any text after "=cut" on the line,
189 it must be ignored. Examples:
190
191 =cut
192
193 =cut The documentation ends here.
194
195 =cut
196 # This is the first line of program text.
197 sub foo { # This is the second.
198
199 It is an error to try to start a Pod block with a "=cut" command.
200 In that case, the Pod processor must halt parsing of the input
201 file, and must by default emit a warning.
202
203 "=over"
204 This command indicates that this is the start of a list/indent
205 region. If there is any text following the "=over", it must
206 consist of only a nonzero positive numeral. The semantics of this
207 numeral is explained in the "About =over...=back Regions" section,
208 further below. Formatting codes are not expanded. Examples:
209
210 =over 3
211
212 =over 3.5
213
214 =over
215
216 "=item"
217 This command indicates that an item in a list begins here.
218 Formatting codes are processed. The semantics of the (optional)
219 text in the remainder of this paragraph are explained in the "About
220 =over...=back Regions" section, further below. Examples:
221
222 =item
223
224 =item *
225
226 =item *
227
228 =item 14
229
230 =item 3.
231
232 =item C<< $thing->stuff(I<dodad>) >>
233
234 =item For transporting us beyond seas to be tried for pretended
235 offenses
236
237 =item He is at this time transporting large armies of foreign
238 mercenaries to complete the works of death, desolation and
239 tyranny, already begun with circumstances of cruelty and perfidy
240 scarcely paralleled in the most barbarous ages, and totally
241 unworthy the head of a civilized nation.
242
243 "=back"
244 This command indicates that this is the end of the region begun by
245 the most recent "=over" command. It permits no text after the
246 "=back" command.
247
248 "=begin formatname"
249 "=begin formatname parameter"
250 This marks the following paragraphs (until the matching "=end
251 formatname") as being for some special kind of processing. Unless
252 "formatname" begins with a colon, the contained non-command
253 paragraphs are data paragraphs. But if "formatname" does begin
254 with a colon, then non-command paragraphs are ordinary paragraphs
255 or data paragraphs. This is discussed in detail in the section
256 "About Data Paragraphs and "=begin/=end" Regions".
257
258 It is advised that formatnames match the regexp
259 "m/\A:?[-a-zA-Z0-9_]+\z/". Everything following whitespace after
260 the formatname is a parameter that may be used by the formatter
261 when dealing with this region. This parameter must not be repeated
262 in the "=end" paragraph. Implementors should anticipate future
263 expansion in the semantics and syntax of the first parameter to
264 "=begin"/"=end"/"=for".
265
266 "=end formatname"
267 This marks the end of the region opened by the matching "=begin
268 formatname" region. If "formatname" is not the formatname of the
269 most recent open "=begin formatname" region, then this is an error,
270 and must generate an error message. This is discussed in detail in
271 the section "About Data Paragraphs and "=begin/=end" Regions".
272
273 "=for formatname text..."
274 This is synonymous with:
275
276 =begin formatname
277
278 text...
279
280 =end formatname
281
282 That is, it creates a region consisting of a single paragraph; that
283 paragraph is to be treated as a normal paragraph if "formatname"
284 begins with a ":"; if "formatname" doesn't begin with a colon, then
285 "text..." will constitute a data paragraph. There is no way to use
286 "=for formatname text..." to express "text..." as a verbatim
287 paragraph.
288
289 "=encoding encodingname"
290 This command, which should occur early in the document (at least
291 before any non-US-ASCII data!), declares that this document is
292 encoded in the encoding encodingname, which must be an encoding
293 name that Encode recognizes. (Encode's list of supported
294 encodings, in Encode::Supported, is useful here.) If the Pod
295 parser cannot decode the declared encoding, it should emit a
296 warning and may abort parsing the document altogether.
297
298 A document having more than one "=encoding" line should be
299 considered an error. Pod processors may silently tolerate this if
300 the not-first "=encoding" lines are just duplicates of the first
301 one (e.g., if there's a "=encoding utf8" line, and later on another
302 "=encoding utf8" line). But Pod processors should complain if
303 there are contradictory "=encoding" lines in the same document
304 (e.g., if there is a "=encoding utf8" early in the document and
305 "=encoding big5" later). Pod processors that recognize BOMs may
306 also complain if they see an "=encoding" line that contradicts the
307 BOM (e.g., if a document with a UTF-16LE BOM has an "=encoding
308 shiftjis" line).
309
310 If a Pod processor sees any command other than the ones listed above
311 (like "=head", or "=haed1", or "=stuff", or "=cuttlefish", or "=w123"),
312 that processor must by default treat this as an error. It must not
313 process the paragraph beginning with that command, must by default warn
314 of this as an error, and may abort the parse. A Pod parser may allow a
315 way for particular applications to add to the above list of known
316 commands, and to stipulate, for each additional command, whether
317 formatting codes should be processed.
318
319 Future versions of this specification may add additional commands.
320
322 (Note that in previous drafts of this document and of perlpod,
323 formatting codes were referred to as "interior sequences", and this
324 term may still be found in the documentation for Pod parsers, and in
325 error messages from Pod processors.)
326
327 There are two syntaxes for formatting codes:
328
329 • A formatting code starts with a capital letter (just US-ASCII
330 [A-Z]) followed by a "<", any number of characters, and ending with
331 the first matching ">". Examples:
332
333 That's what I<you> think!
334
335 What's C<CORE::dump()> for?
336
337 X<C<chmod> and C<unlink()> Under Different Operating Systems>
338
339 • A formatting code starts with a capital letter (just US-ASCII
340 [A-Z]) followed by two or more "<"'s, one or more whitespace
341 characters, any number of characters, one or more whitespace
342 characters, and ending with the first matching sequence of two or
343 more ">"'s, where the number of ">"'s equals the number of "<"'s in
344 the opening of this formatting code. Examples:
345
346 That's what I<< you >> think!
347
348 C<<< open(X, ">>thing.dat") || die $! >>>
349
350 B<< $foo->bar(); >>
351
352 With this syntax, the whitespace character(s) after the "C<<<" and
353 before the ">>>" (or whatever letter) are not renderable. They do
354 not signify whitespace, are merely part of the formatting codes
355 themselves. That is, these are all synonymous:
356
357 C<thing>
358 C<< thing >>
359 C<< thing >>
360 C<<< thing >>>
361 C<<<<
362 thing
363 >>>>
364
365 and so on.
366
367 Finally, the multiple-angle-bracket form does not alter the
368 interpretation of nested formatting codes, meaning that the
369 following four example lines are identical in meaning:
370
371 B<example: C<$a E<lt>=E<gt> $b>>
372
373 B<example: C<< $a <=> $b >>>
374
375 B<example: C<< $a E<lt>=E<gt> $b >>>
376
377 B<<< example: C<< $a E<lt>=E<gt> $b >> >>>
378
379 In parsing Pod, a notably tricky part is the correct parsing of
380 (potentially nested!) formatting codes. Implementors should consult
381 the code in the "parse_text" routine in Pod::Parser as an example of a
382 correct implementation.
383
384 "I<text>" -- italic text
385 See the brief discussion in "Formatting Codes" in perlpod.
386
387 "B<text>" -- bold text
388 See the brief discussion in "Formatting Codes" in perlpod.
389
390 "C<code>" -- code text
391 See the brief discussion in "Formatting Codes" in perlpod.
392
393 "F<filename>" -- style for filenames
394 See the brief discussion in "Formatting Codes" in perlpod.
395
396 "X<topic name>" -- an index entry
397 See the brief discussion in "Formatting Codes" in perlpod.
398
399 This code is unusual in that most formatters completely discard
400 this code and its content. Other formatters will render it with
401 invisible codes that can be used in building an index of the
402 current document.
403
404 "Z<>" -- a null (zero-effect) formatting code
405 Discussed briefly in "Formatting Codes" in perlpod.
406
407 This code is unusual in that it should have no content. That is, a
408 processor may complain if it sees "Z<potatoes>". Whether or not it
409 complains, the potatoes text should ignored.
410
411 "L<name>" -- a hyperlink
412 The complicated syntaxes of this code are discussed at length in
413 "Formatting Codes" in perlpod, and implementation details are
414 discussed below, in "About L<...> Codes". Parsing the contents of
415 L<content> is tricky. Notably, the content has to be checked for
416 whether it looks like a URL, or whether it has to be split on
417 literal "|" and/or "/" (in the right order!), and so on, before
418 E<...> codes are resolved.
419
420 "E<escape>" -- a character escape
421 See "Formatting Codes" in perlpod, and several points in "Notes on
422 Implementing Pod Processors".
423
424 "S<text>" -- text contains non-breaking spaces
425 This formatting code is syntactically simple, but semantically
426 complex. What it means is that each space in the printable content
427 of this code signifies a non-breaking space.
428
429 Consider:
430
431 C<$x ? $y : $z>
432
433 S<C<$x ? $y : $z>>
434
435 Both signify the monospace (c[ode] style) text consisting of "$x",
436 one space, "?", one space, ":", one space, "$z". The difference is
437 that in the latter, with the S code, those spaces are not "normal"
438 spaces, but instead are non-breaking spaces.
439
440 If a Pod processor sees any formatting code other than the ones listed
441 above (as in "N<...>", or "Q<...>", etc.), that processor must by
442 default treat this as an error. A Pod parser may allow a way for
443 particular applications to add to the above list of known formatting
444 codes; a Pod parser might even allow a way to stipulate, for each
445 additional command, whether it requires some form of special
446 processing, as L<...> does.
447
448 Future versions of this specification may add additional formatting
449 codes.
450
451 Historical note: A few older Pod processors would not see a ">" as
452 closing a "C<" code, if the ">" was immediately preceded by a "-".
453 This was so that this:
454
455 C<$foo->bar>
456
457 would parse as equivalent to this:
458
459 C<$foo-E<gt>bar>
460
461 instead of as equivalent to a "C" formatting code containing only
462 "$foo-", and then a "bar>" outside the "C" formatting code. This
463 problem has since been solved by the addition of syntaxes like this:
464
465 C<< $foo->bar >>
466
467 Compliant parsers must not treat "->" as special.
468
469 Formatting codes absolutely cannot span paragraphs. If a code is
470 opened in one paragraph, and no closing code is found by the end of
471 that paragraph, the Pod parser must close that formatting code, and
472 should complain (as in "Unterminated I code in the paragraph starting
473 at line 123: 'Time objects are not...'"). So these two paragraphs:
474
475 I<I told you not to do this!
476
477 Don't make me say it again!>
478
479 ...must not be parsed as two paragraphs in italics (with the I code
480 starting in one paragraph and starting in another.) Instead, the first
481 paragraph should generate a warning, but that aside, the above code
482 must parse as if it were:
483
484 I<I told you not to do this!>
485
486 Don't make me say it again!E<gt>
487
488 (In SGMLish jargon, all Pod commands are like block-level elements,
489 whereas all Pod formatting codes are like inline-level elements.)
490
492 The following is a long section of miscellaneous requirements and
493 suggestions to do with Pod processing.
494
495 • Pod formatters should tolerate lines in verbatim blocks that are of
496 any length, even if that means having to break them (possibly
497 several times, for very long lines) to avoid text running off the
498 side of the page. Pod formatters may warn of such line-breaking.
499 Such warnings are particularly appropriate for lines are over 100
500 characters long, which are usually not intentional.
501
502 • Pod parsers must recognize all of the three well-known newline
503 formats: CR, LF, and CRLF. See perlport.
504
505 • Pod parsers should accept input lines that are of any length.
506
507 • Since Perl recognizes a Unicode Byte Order Mark at the start of
508 files as signaling that the file is Unicode encoded as in UTF-16
509 (whether big-endian or little-endian) or UTF-8, Pod parsers should
510 do the same. Otherwise, the character encoding should be
511 understood as being UTF-8 if the first highbit byte sequence in the
512 file seems valid as a UTF-8 sequence, or otherwise as CP-1252
513 (earlier versions of this specification used Latin-1 instead of
514 CP-1252).
515
516 Future versions of this specification may specify how Pod can
517 accept other encodings. Presumably treatment of other encodings in
518 Pod parsing would be as in XML parsing: whatever the encoding
519 declared by a particular Pod file, content is to be stored in
520 memory as Unicode characters.
521
522 • The well known Unicode Byte Order Marks are as follows: if the
523 file begins with the two literal byte values 0xFE 0xFF, this is the
524 BOM for big-endian UTF-16. If the file begins with the two literal
525 byte value 0xFF 0xFE, this is the BOM for little-endian UTF-16. On
526 an ASCII platform, if the file begins with the three literal byte
527 values 0xEF 0xBB 0xBF, this is the BOM for UTF-8. A mechanism
528 portable to EBCDIC platforms is to:
529
530 my $utf8_bom = "\x{FEFF}";
531 utf8::encode($utf8_bom);
532
533 • A naive, but often sufficient heuristic on ASCII platforms, for
534 testing the first highbit byte-sequence in a BOM-less file (whether
535 in code or in Pod!), to see whether that sequence is valid as UTF-8
536 (RFC 2279) is to check whether that the first byte in the sequence
537 is in the range 0xC2 - 0xFD and whether the next byte is in the
538 range 0x80 - 0xBF. If so, the parser may conclude that this file
539 is in UTF-8, and all highbit sequences in the file should be
540 assumed to be UTF-8. Otherwise the parser should treat the file as
541 being in CP-1252. (A better check, and which works on EBCDIC
542 platforms as well, is to pass a copy of the sequence to
543 utf8::decode() which performs a full validity check on the sequence
544 and returns TRUE if it is valid UTF-8, FALSE otherwise. This
545 function is always pre-loaded, is fast because it is written in C,
546 and will only get called at most once, so you don't need to avoid
547 it out of performance concerns.) In the unlikely circumstance that
548 the first highbit sequence in a truly non-UTF-8 file happens to
549 appear to be UTF-8, one can cater to our heuristic (as well as any
550 more intelligent heuristic) by prefacing that line with a comment
551 line containing a highbit sequence that is clearly not valid as
552 UTF-8. A line consisting of simply "#", an e-acute, and any non-
553 highbit byte, is sufficient to establish this file's encoding.
554
555 • Pod processors must treat a "=for [label] [content...]" paragraph
556 as meaning the same thing as a "=begin [label]" paragraph, content,
557 and an "=end [label]" paragraph. (The parser may conflate these
558 two constructs, or may leave them distinct, in the expectation that
559 the formatter will nevertheless treat them the same.)
560
561 • When rendering Pod to a format that allows comments (i.e., to
562 nearly any format other than plaintext), a Pod formatter must
563 insert comment text identifying its name and version number, and
564 the name and version numbers of any modules it might be using to
565 process the Pod. Minimal examples:
566
567 %% POD::Pod2PS v3.14159, using POD::Parser v1.92
568
569 <!-- Pod::HTML v3.14159, using POD::Parser v1.92 -->
570
571 {\doccomm generated by Pod::Tree::RTF 3.14159 using Pod::Tree 1.08}
572
573 .\" Pod::Man version 3.14159, using POD::Parser version 1.92
574
575 Formatters may also insert additional comments, including: the
576 release date of the Pod formatter program, the contact address for
577 the author(s) of the formatter, the current time, the name of input
578 file, the formatting options in effect, version of Perl used, etc.
579
580 Formatters may also choose to note errors/warnings as comments,
581 besides or instead of emitting them otherwise (as in messages to
582 STDERR, or "die"ing).
583
584 • Pod parsers may emit warnings or error messages ("Unknown E code
585 E<zslig>!") to STDERR (whether through printing to STDERR, or
586 "warn"ing/"carp"ing, or "die"ing/"croak"ing), but must allow
587 suppressing all such STDERR output, and instead allow an option for
588 reporting errors/warnings in some other way, whether by triggering
589 a callback, or noting errors in some attribute of the document
590 object, or some similarly unobtrusive mechanism -- or even by
591 appending a "Pod Errors" section to the end of the parsed form of
592 the document.
593
594 • In cases of exceptionally aberrant documents, Pod parsers may abort
595 the parse. Even then, using "die"ing/"croak"ing is to be avoided;
596 where possible, the parser library may simply close the input file
597 and add text like "*** Formatting Aborted ***" to the end of the
598 (partial) in-memory document.
599
600 • In paragraphs where formatting codes (like E<...>, B<...>) are
601 understood (i.e., not verbatim paragraphs, but including ordinary
602 paragraphs, and command paragraphs that produce renderable text,
603 like "=head1"), literal whitespace should generally be considered
604 "insignificant", in that one literal space has the same meaning as
605 any (nonzero) number of literal spaces, literal newlines, and
606 literal tabs (as long as this produces no blank lines, since those
607 would terminate the paragraph). Pod parsers should compact literal
608 whitespace in each processed paragraph, but may provide an option
609 for overriding this (since some processing tasks do not require
610 it), or may follow additional special rules (for example, specially
611 treating period-space-space or period-newline sequences).
612
613 • Pod parsers should not, by default, try to coerce apostrophe (')
614 and quote (") into smart quotes (little 9's, 66's, 99's, etc), nor
615 try to turn backtick (`) into anything else but a single backtick
616 character (distinct from an open quote character!), nor "--" into
617 anything but two minus signs. They must never do any of those
618 things to text in C<...> formatting codes, and never ever to text
619 in verbatim paragraphs.
620
621 • When rendering Pod to a format that has two kinds of hyphens (-),
622 one that's a non-breaking hyphen, and another that's a breakable
623 hyphen (as in "object-oriented", which can be split across lines as
624 "object-", newline, "oriented"), formatters are encouraged to
625 generally translate "-" to non-breaking hyphen, but may apply
626 heuristics to convert some of these to breaking hyphens.
627
628 • Pod formatters should make reasonable efforts to keep words of Perl
629 code from being broken across lines. For example, "Foo::Bar" in
630 some formatting systems is seen as eligible for being broken across
631 lines as "Foo::" newline "Bar" or even "Foo::-" newline "Bar".
632 This should be avoided where possible, either by disabling all
633 line-breaking in mid-word, or by wrapping particular words with
634 internal punctuation in "don't break this across lines" codes
635 (which in some formats may not be a single code, but might be a
636 matter of inserting non-breaking zero-width spaces between every
637 pair of characters in a word.)
638
639 • Pod parsers should, by default, expand tabs in verbatim paragraphs
640 as they are processed, before passing them to the formatter or
641 other processor. Parsers may also allow an option for overriding
642 this.
643
644 • Pod parsers should, by default, remove newlines from the end of
645 ordinary and verbatim paragraphs before passing them to the
646 formatter. For example, while the paragraph you're reading now
647 could be considered, in Pod source, to end with (and contain) the
648 newline(s) that end it, it should be processed as ending with (and
649 containing) the period character that ends this sentence.
650
651 • Pod parsers, when reporting errors, should make some effort to
652 report an approximate line number ("Nested E<>'s in Paragraph #52,
653 near line 633 of Thing/Foo.pm!"), instead of merely noting the
654 paragraph number ("Nested E<>'s in Paragraph #52 of
655 Thing/Foo.pm!"). Where this is problematic, the paragraph number
656 should at least be accompanied by an excerpt from the paragraph
657 ("Nested E<>'s in Paragraph #52 of Thing/Foo.pm, which begins
658 'Read/write accessor for the C<interest rate> attribute...'").
659
660 • Pod parsers, when processing a series of verbatim paragraphs one
661 after another, should consider them to be one large verbatim
662 paragraph that happens to contain blank lines. I.e., these two
663 lines, which have a blank line between them:
664
665 use Foo;
666
667 print Foo->VERSION
668
669 should be unified into one paragraph ("\tuse Foo;\n\n\tprint
670 Foo->VERSION") before being passed to the formatter or other
671 processor. Parsers may also allow an option for overriding this.
672
673 While this might be too cumbersome to implement in event-based Pod
674 parsers, it is straightforward for parsers that return parse trees.
675
676 • Pod formatters, where feasible, are advised to avoid splitting
677 short verbatim paragraphs (under twelve lines, say) across pages.
678
679 • Pod parsers must treat a line with only spaces and/or tabs on it as
680 a "blank line" such as separates paragraphs. (Some older parsers
681 recognized only two adjacent newlines as a "blank line" but would
682 not recognize a newline, a space, and a newline, as a blank line.
683 This is noncompliant behavior.)
684
685 • Authors of Pod formatters/processors should make every effort to
686 avoid writing their own Pod parser. There are already several in
687 CPAN, with a wide range of interface styles -- and one of them,
688 Pod::Simple, comes with modern versions of Perl.
689
690 • Characters in Pod documents may be conveyed either as literals, or
691 by number in E<n> codes, or by an equivalent mnemonic, as in
692 E<eacute> which is exactly equivalent to E<233>. The numbers are
693 the Latin1/Unicode values, even on EBCDIC platforms.
694
695 When referring to characters by using a E<n> numeric code, numbers
696 in the range 32-126 refer to those well known US-ASCII characters
697 (also defined there by Unicode, with the same meaning), which all
698 Pod formatters must render faithfully. Characters whose E<>
699 numbers are in the ranges 0-31 and 127-159 should not be used
700 (neither as literals, nor as E<number> codes), except for the
701 literal byte-sequences for newline (ASCII 13, ASCII 13 10, or ASCII
702 10), and tab (ASCII 9).
703
704 Numbers in the range 160-255 refer to Latin-1 characters (also
705 defined there by Unicode, with the same meaning). Numbers above
706 255 should be understood to refer to Unicode characters.
707
708 • Be warned that some formatters cannot reliably render characters
709 outside 32-126; and many are able to handle 32-126 and 160-255, but
710 nothing above 255.
711
712 • Besides the well-known "E<lt>" and "E<gt>" codes for less-than and
713 greater-than, Pod parsers must understand "E<sol>" for "/"
714 (solidus, slash), and "E<verbar>" for "|" (vertical bar, pipe).
715 Pod parsers should also understand "E<lchevron>" and "E<rchevron>"
716 as legacy codes for characters 171 and 187, i.e., "left-pointing
717 double angle quotation mark" = "left pointing guillemet" and
718 "right-pointing double angle quotation mark" = "right pointing
719 guillemet". (These look like little "<<" and ">>", and they are
720 now preferably expressed with the HTML/XHTML codes "E<laquo>" and
721 "E<raquo>".)
722
723 • Pod parsers should understand all "E<html>" codes as defined in the
724 entity declarations in the most recent XHTML specification at
725 "www.W3.org". Pod parsers must understand at least the entities
726 that define characters in the range 160-255 (Latin-1). Pod
727 parsers, when faced with some unknown "E<identifier>" code,
728 shouldn't simply replace it with nullstring (by default, at least),
729 but may pass it through as a string consisting of the literal
730 characters E, less-than, identifier, greater-than. Or Pod parsers
731 may offer the alternative option of processing such unknown
732 "E<identifier>" codes by firing an event especially for such codes,
733 or by adding a special node-type to the in-memory document tree.
734 Such "E<identifier>" may have special meaning to some processors,
735 or some processors may choose to add them to a special error
736 report.
737
738 • Pod parsers must also support the XHTML codes "E<quot>" for
739 character 34 (doublequote, "), "E<amp>" for character 38
740 (ampersand, &), and "E<apos>" for character 39 (apostrophe, ').
741
742 • Note that in all cases of "E<whatever>", whatever (whether an
743 htmlname, or a number in any base) must consist only of
744 alphanumeric characters -- that is, whatever must match
745 "m/\A\w+\z/". So "E< 0 1 2 3 >" is invalid, because it contains
746 spaces, which aren't alphanumeric characters. This presumably does
747 not need special treatment by a Pod processor; " 0 1 2 3 " doesn't
748 look like a number in any base, so it would presumably be looked up
749 in the table of HTML-like names. Since there isn't (and cannot be)
750 an HTML-like entity called " 0 1 2 3 ", this will be treated as an
751 error. However, Pod processors may treat "E< 0 1 2 3 >" or
752 "E<e-acute>" as syntactically invalid, potentially earning a
753 different error message than the error message (or warning, or
754 event) generated by a merely unknown (but theoretically valid)
755 htmlname, as in "E<qacute>" [sic]. However, Pod parsers are not
756 required to make this distinction.
757
758 • Note that E<number> must not be interpreted as simply "codepoint
759 number in the current/native character set". It always means only
760 "the character represented by codepoint number in Unicode." (This
761 is identical to the semantics of &#number; in XML.)
762
763 This will likely require many formatters to have tables mapping
764 from treatable Unicode codepoints (such as the "\xE9" for the
765 e-acute character) to the escape sequences or codes necessary for
766 conveying such sequences in the target output format. A converter
767 to *roff would, for example know that "\xE9" (whether conveyed
768 literally, or via a E<...> sequence) is to be conveyed as "e\\*'".
769 Similarly, a program rendering Pod in a Mac OS application window,
770 would presumably need to know that "\xE9" maps to codepoint 142 in
771 MacRoman encoding that (at time of writing) is native for Mac OS.
772 Such Unicode2whatever mappings are presumably already widely
773 available for common output formats. (Such mappings may be
774 incomplete! Implementers are not expected to bend over backwards
775 in an attempt to render Cherokee syllabics, Etruscan runes,
776 Byzantine musical symbols, or any of the other weird things that
777 Unicode can encode.) And if a Pod document uses a character not
778 found in such a mapping, the formatter should consider it an
779 unrenderable character.
780
781 • If, surprisingly, the implementor of a Pod formatter can't find a
782 satisfactory pre-existing table mapping from Unicode characters to
783 escapes in the target format (e.g., a decent table of Unicode
784 characters to *roff escapes), it will be necessary to build such a
785 table. If you are in this circumstance, you should begin with the
786 characters in the range 0x00A0 - 0x00FF, which is mostly the
787 heavily used accented characters. Then proceed (as patience
788 permits and fastidiousness compels) through the characters that the
789 (X)HTML standards groups judged important enough to merit mnemonics
790 for. These are declared in the (X)HTML specifications at the
791 www.W3.org site. At time of writing (September 2001), the most
792 recent entity declaration files are:
793
794 http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
795 http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
796 http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent
797
798 Then you can progress through any remaining notable Unicode
799 characters in the range 0x2000-0x204D (consult the character tables
800 at www.unicode.org), and whatever else strikes your fancy. For
801 example, in xhtml-symbol.ent, there is the entry:
802
803 <!ENTITY infin "∞"> <!-- infinity, U+221E ISOtech -->
804
805 While the mapping "infin" to the character "\x{221E}" will
806 (hopefully) have been already handled by the Pod parser, the
807 presence of the character in this file means that it's reasonably
808 important enough to include in a formatter's table that maps from
809 notable Unicode characters to the codes necessary for rendering
810 them. So for a Unicode-to-*roff mapping, for example, this would
811 merit the entry:
812
813 "\x{221E}" => '\(in',
814
815 It is eagerly hoped that in the future, increasing numbers of
816 formats (and formatters) will support Unicode characters directly
817 (as (X)HTML does with "∞", "∞", or "∞"),
818 reducing the need for idiosyncratic mappings of
819 Unicode-to-my_escapes.
820
821 • It is up to individual Pod formatter to display good judgement when
822 confronted with an unrenderable character (which is distinct from
823 an unknown E<thing> sequence that the parser couldn't resolve to
824 anything, renderable or not). It is good practice to map Latin
825 letters with diacritics (like "E<eacute>"/"E<233>") to the
826 corresponding unaccented US-ASCII letters (like a simple character
827 101, "e"), but clearly this is often not feasible, and an
828 unrenderable character may be represented as "?", or the like. In
829 attempting a sane fallback (as from E<233> to "e"), Pod formatters
830 may use the %Latin1Code_to_fallback table in Pod::Escapes, or
831 Text::Unidecode, if available.
832
833 For example, this Pod text:
834
835 magic is enabled if you set C<$Currency> to 'E<euro>'.
836
837 may be rendered as: "magic is enabled if you set $Currency to '?'"
838 or as "magic is enabled if you set $Currency to '[euro]'", or as
839 "magic is enabled if you set $Currency to '[x20AC]', etc.
840
841 A Pod formatter may also note, in a comment or warning, a list of
842 what unrenderable characters were encountered.
843
844 • E<...> may freely appear in any formatting code (other than in
845 another E<...> or in an Z<>). That is, "X<The E<euro>1,000,000
846 Solution>" is valid, as is "L<The E<euro>1,000,000
847 Solution|Million::Euros>".
848
849 • Some Pod formatters output to formats that implement non-breaking
850 spaces as an individual character (which I'll call "NBSP"), and
851 others output to formats that implement non-breaking spaces just as
852 spaces wrapped in a "don't break this across lines" code. Note
853 that at the level of Pod, both sorts of codes can occur: Pod can
854 contain a NBSP character (whether as a literal, or as a "E<160>" or
855 "E<nbsp>" code); and Pod can contain "S<foo I<bar> baz>" codes,
856 where "mere spaces" (character 32) in such codes are taken to
857 represent non-breaking spaces. Pod parsers should consider
858 supporting the optional parsing of "S<foo I<bar> baz>" as if it
859 were "fooNBSPI<bar>NBSPbaz", and, going the other way, the optional
860 parsing of groups of words joined by NBSP's as if each group were
861 in a S<...> code, so that formatters may use the representation
862 that maps best to what the output format demands.
863
864 • Some processors may find that the "S<...>" code is easiest to
865 implement by replacing each space in the parse tree under the
866 content of the S, with an NBSP. But note: the replacement should
867 apply not to spaces in all text, but only to spaces in printable
868 text. (This distinction may or may not be evident in the
869 particular tree/event model implemented by the Pod parser.) For
870 example, consider this unusual case:
871
872 S<L</Autoloaded Functions>>
873
874 This means that the space in the middle of the visible link text
875 must not be broken across lines. In other words, it's the same as
876 this:
877
878 L<"AutoloadedE<160>Functions"/Autoloaded Functions>
879
880 However, a misapplied space-to-NBSP replacement could (wrongly)
881 produce something equivalent to this:
882
883 L<"AutoloadedE<160>Functions"/AutoloadedE<160>Functions>
884
885 ...which is almost definitely not going to work as a hyperlink
886 (assuming this formatter outputs a format supporting hypertext).
887
888 Formatters may choose to just not support the S format code,
889 especially in cases where the output format simply has no NBSP
890 character/code and no code for "don't break this stuff across
891 lines".
892
893 • Besides the NBSP character discussed above, implementors are
894 reminded of the existence of the other "special" character in
895 Latin-1, the "soft hyphen" character, also known as "discretionary
896 hyphen", i.e. "E<173>" = "E<0xAD>" = "E<shy>"). This character
897 expresses an optional hyphenation point. That is, it normally
898 renders as nothing, but may render as a "-" if a formatter breaks
899 the word at that point. Pod formatters should, as appropriate, do
900 one of the following: 1) render this with a code with the same
901 meaning (e.g., "\-" in RTF), 2) pass it through in the expectation
902 that the formatter understands this character as such, or 3) delete
903 it.
904
905 For example:
906
907 sigE<shy>action
908 manuE<shy>script
909 JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
910
911 These signal to a formatter that if it is to hyphenate "sigaction"
912 or "manuscript", then it should be done as "sig-[linebreak]action"
913 or "manu-[linebreak]script" (and if it doesn't hyphenate it, then
914 the "E<shy>" doesn't show up at all). And if it is to hyphenate
915 "Jarkko" and/or "Hietaniemi", it can do so only at the points where
916 there is a "E<shy>" code.
917
918 In practice, it is anticipated that this character will not be used
919 often, but formatters should either support it, or delete it.
920
921 • If you think that you want to add a new command to Pod (like, say,
922 a "=biblio" command), consider whether you could get the same
923 effect with a for or begin/end sequence: "=for biblio ..." or
924 "=begin biblio" ... "=end biblio". Pod processors that don't
925 understand "=for biblio", etc, will simply ignore it, whereas they
926 may complain loudly if they see "=biblio".
927
928 • Throughout this document, "Pod" has been the preferred spelling for
929 the name of the documentation format. One may also use "POD" or
930 "pod". For the documentation that is (typically) in the Pod
931 format, you may use "pod", or "Pod", or "POD". Understanding these
932 distinctions is useful; but obsessing over how to spell them,
933 usually is not.
934
936 As you can tell from a glance at perlpod, the L<...> code is the most
937 complex of the Pod formatting codes. The points below will hopefully
938 clarify what it means and how processors should deal with it.
939
940 • In parsing an L<...> code, Pod parsers must distinguish at least
941 four attributes:
942
943 First:
944 The link-text. If there is none, this must be "undef". (E.g.,
945 in "L<Perl Functions|perlfunc>", the link-text is "Perl
946 Functions". In "L<Time::HiRes>" and even "L<|Time::HiRes>",
947 there is no link text. Note that link text may contain
948 formatting.)
949
950 Second:
951 The possibly inferred link-text; i.e., if there was no real
952 link text, then this is the text that we'll infer in its place.
953 (E.g., for "L<Getopt::Std>", the inferred link text is
954 "Getopt::Std".)
955
956 Third:
957 The name or URL, or "undef" if none. (E.g., in "L<Perl
958 Functions|perlfunc>", the name (also sometimes called the page)
959 is "perlfunc". In "L</CAVEATS>", the name is "undef".)
960
961 Fourth:
962 The section (AKA "item" in older perlpods), or "undef" if none.
963 E.g., in "L<Getopt::Std/DESCRIPTION>", "DESCRIPTION" is the
964 section. (Note that this is not the same as a manpage section
965 like the "5" in "man 5 crontab". "Section Foo" in the Pod
966 sense means the part of the text that's introduced by the
967 heading or item whose text is "Foo".)
968
969 Pod parsers may also note additional attributes including:
970
971 Fifth:
972 A flag for whether item 3 (if present) is a URL (like
973 "http://lists.perl.org" is), in which case there should be no
974 section attribute; a Pod name (like "perldoc" and "Getopt::Std"
975 are); or possibly a man page name (like "crontab(5)" is).
976
977 Sixth:
978 The raw original L<...> content, before text is split on "|",
979 "/", etc, and before E<...> codes are expanded.
980
981 (The above were numbered only for concise reference below. It is
982 not a requirement that these be passed as an actual list or array.)
983
984 For example:
985
986 L<Foo::Bar>
987 => undef, # link text
988 "Foo::Bar", # possibly inferred link text
989 "Foo::Bar", # name
990 undef, # section
991 'pod', # what sort of link
992 "Foo::Bar" # original content
993
994 L<Perlport's section on NL's|perlport/Newlines>
995 => "Perlport's section on NL's", # link text
996 "Perlport's section on NL's", # possibly inferred link text
997 "perlport", # name
998 "Newlines", # section
999 'pod', # what sort of link
1000 "Perlport's section on NL's|perlport/Newlines"
1001 # original content
1002
1003 L<perlport/Newlines>
1004 => undef, # link text
1005 '"Newlines" in perlport', # possibly inferred link text
1006 "perlport", # name
1007 "Newlines", # section
1008 'pod', # what sort of link
1009 "perlport/Newlines" # original content
1010
1011 L<crontab(5)/"DESCRIPTION">
1012 => undef, # link text
1013 '"DESCRIPTION" in crontab(5)', # possibly inferred link text
1014 "crontab(5)", # name
1015 "DESCRIPTION", # section
1016 'man', # what sort of link
1017 'crontab(5)/"DESCRIPTION"' # original content
1018
1019 L</Object Attributes>
1020 => undef, # link text
1021 '"Object Attributes"', # possibly inferred link text
1022 undef, # name
1023 "Object Attributes", # section
1024 'pod', # what sort of link
1025 "/Object Attributes" # original content
1026
1027 L<https://www.perl.org/>
1028 => undef, # link text
1029 "https://www.perl.org/", # possibly inferred link text
1030 "https://www.perl.org/", # name
1031 undef, # section
1032 'url', # what sort of link
1033 "https://www.perl.org/" # original content
1034
1035 L<Perl.org|https://www.perl.org/>
1036 => "Perl.org", # link text
1037 "https://www.perl.org/", # possibly inferred link text
1038 "https://www.perl.org/", # name
1039 undef, # section
1040 'url', # what sort of link
1041 "Perl.org|https://www.perl.org/" # original content
1042
1043 Note that you can distinguish URL-links from anything else by the
1044 fact that they match "m/\A\w+:[^:\s]\S*\z/". So
1045 "L<http://www.perl.com>" is a URL, but "L<HTTP::Response>" isn't.
1046
1047 • In case of L<...> codes with no "text|" part in them, older
1048 formatters have exhibited great variation in actually displaying
1049 the link or cross reference. For example, L<crontab(5)> would
1050 render as "the crontab(5) manpage", or "in the crontab(5) manpage"
1051 or just "crontab(5)".
1052
1053 Pod processors must now treat "text|"-less links as follows:
1054
1055 L<name> => L<name|name>
1056 L</section> => L<"section"|/section>
1057 L<name/section> => L<"section" in name|name/section>
1058
1059 • Note that section names might contain markup. I.e., if a section
1060 starts with:
1061
1062 =head2 About the C<-M> Operator
1063
1064 or with:
1065
1066 =item About the C<-M> Operator
1067
1068 then a link to it would look like this:
1069
1070 L<somedoc/About the C<-M> Operator>
1071
1072 Formatters may choose to ignore the markup for purposes of
1073 resolving the link and use only the renderable characters in the
1074 section name, as in:
1075
1076 <h1><a name="About_the_-M_Operator">About the <code>-M</code>
1077 Operator</h1>
1078
1079 ...
1080
1081 <a href="somedoc#About_the_-M_Operator">About the <code>-M</code>
1082 Operator" in somedoc</a>
1083
1084 • Previous versions of perlpod distinguished "L<name/"section">"
1085 links from "L<name/item>" links (and their targets). These have
1086 been merged syntactically and semantically in the current
1087 specification, and section can refer either to a "=headn Heading
1088 Content" command or to a "=item Item Content" command. This
1089 specification does not specify what behavior should be in the case
1090 of a given document having several things all seeming to produce
1091 the same section identifier (e.g., in HTML, several things all
1092 producing the same anchorname in <a name="anchorname">...</a>
1093 elements). Where Pod processors can control this behavior, they
1094 should use the first such anchor. That is, "L<Foo/Bar>" refers to
1095 the first "Bar" section in Foo.
1096
1097 But for some processors/formats this cannot be easily controlled;
1098 as with the HTML example, the behavior of multiple ambiguous <a
1099 name="anchorname">...</a> is most easily just left up to browsers
1100 to decide.
1101
1102 • In a "L<text|...>" code, text may contain formatting codes for
1103 formatting or for E<...> escapes, as in:
1104
1105 L<B<ummE<234>stuff>|...>
1106
1107 For "L<...>" codes without a "name|" part, only "E<...>" and "Z<>"
1108 codes may occur. That is, authors should not use
1109 ""L<B<Foo::Bar>>"".
1110
1111 Note, however, that formatting codes and Z<>'s can occur in any and
1112 all parts of an L<...> (i.e., in name, section, text, and url).
1113
1114 Authors must not nest L<...> codes. For example, "L<The
1115 L<Foo::Bar> man page>" should be treated as an error.
1116
1117 • Note that Pod authors may use formatting codes inside the "text"
1118 part of "L<text|name>" (and so on for L<text|/"sec">).
1119
1120 In other words, this is valid:
1121
1122 Go read L<the docs on C<$.>|perlvar/"$.">
1123
1124 Some output formats that do allow rendering "L<...>" codes as
1125 hypertext, might not allow the link-text to be formatted; in that
1126 case, formatters will have to just ignore that formatting.
1127
1128 • At time of writing, "L<name>" values are of two types: either the
1129 name of a Pod page like "L<Foo::Bar>" (which might be a real Perl
1130 module or program in an @INC / PATH directory, or a .pod file in
1131 those places); or the name of a Unix man page, like
1132 "L<crontab(5)>". In theory, "L<chmod>" is ambiguous between a Pod
1133 page called "chmod", or the Unix man page "chmod" (in whatever man-
1134 section). However, the presence of a string in parens, as in
1135 "crontab(5)", is sufficient to signal that what is being discussed
1136 is not a Pod page, and so is presumably a Unix man page. The
1137 distinction is of no importance to many Pod processors, but some
1138 processors that render to hypertext formats may need to distinguish
1139 them in order to know how to render a given "L<foo>" code.
1140
1141 • Previous versions of perlpod allowed for a "L<section>" syntax (as
1142 in "L<Object Attributes>"), which was not easily distinguishable
1143 from "L<name>" syntax and for "L<"section">" which was only
1144 slightly less ambiguous. This syntax is no longer in the
1145 specification, and has been replaced by the "L</section>" syntax
1146 (where the slash was formerly optional). Pod parsers should
1147 tolerate the "L<"section">" syntax, for a while at least. The
1148 suggested heuristic for distinguishing "L<section>" from "L<name>"
1149 is that if it contains any whitespace, it's a section. Pod
1150 processors should warn about this being deprecated syntax.
1151
1153 "=over"..."=back" regions are used for various kinds of list-like
1154 structures. (I use the term "region" here simply as a collective term
1155 for everything from the "=over" to the matching "=back".)
1156
1157 • The non-zero numeric indentlevel in "=over indentlevel" ...
1158 "=back" is used for giving the formatter a clue as to how many
1159 "spaces" (ems, or roughly equivalent units) it should tab over,
1160 although many formatters will have to convert this to an absolute
1161 measurement that may not exactly match with the size of spaces (or
1162 M's) in the document's base font. Other formatters may have to
1163 completely ignore the number. The lack of any explicit indentlevel
1164 parameter is equivalent to an indentlevel value of 4. Pod
1165 processors may complain if indentlevel is present but is not a
1166 positive number matching "m/\A(\d*\.)?\d+\z/".
1167
1168 • Authors of Pod formatters are reminded that "=over" ... "=back" may
1169 map to several different constructs in your output format. For
1170 example, in converting Pod to (X)HTML, it can map to any of
1171 <ul>...</ul>, <ol>...</ol>, <dl>...</dl>, or
1172 <blockquote>...</blockquote>. Similarly, "=item" can map to <li>
1173 or <dt>.
1174
1175 • Each "=over" ... "=back" region should be one of the following:
1176
1177 • An "=over" ... "=back" region containing only "=item *"
1178 commands, each followed by some number of ordinary/verbatim
1179 paragraphs, other nested "=over" ... "=back" regions, "=for..."
1180 paragraphs, and "=begin"..."=end" regions.
1181
1182 (Pod processors must tolerate a bare "=item" as if it were
1183 "=item *".) Whether "*" is rendered as a literal asterisk, an
1184 "o", or as some kind of real bullet character, is left up to
1185 the Pod formatter, and may depend on the level of nesting.
1186
1187 • An "=over" ... "=back" region containing only
1188 "m/\A=item\s+\d+\.?\s*\z/" paragraphs, each one (or each group
1189 of them) followed by some number of ordinary/verbatim
1190 paragraphs, other nested "=over" ... "=back" regions, "=for..."
1191 paragraphs, and/or "=begin"..."=end" codes. Note that the
1192 numbers must start at 1 in each section, and must proceed in
1193 order and without skipping numbers.
1194
1195 (Pod processors must tolerate lines like "=item 1" as if they
1196 were "=item 1.", with the period.)
1197
1198 • An "=over" ... "=back" region containing only "=item [text]"
1199 commands, each one (or each group of them) followed by some
1200 number of ordinary/verbatim paragraphs, other nested "=over"
1201 ... "=back" regions, or "=for..." paragraphs, and
1202 "=begin"..."=end" regions.
1203
1204 The "=item [text]" paragraph should not match
1205 "m/\A=item\s+\d+\.?\s*\z/" or "m/\A=item\s+\*\s*\z/", nor
1206 should it match just "m/\A=item\s*\z/".
1207
1208 • An "=over" ... "=back" region containing no "=item" paragraphs
1209 at all, and containing only some number of ordinary/verbatim
1210 paragraphs, and possibly also some nested "=over" ... "=back"
1211 regions, "=for..." paragraphs, and "=begin"..."=end" regions.
1212 Such an itemless "=over" ... "=back" region in Pod is
1213 equivalent in meaning to a "<blockquote>...</blockquote>"
1214 element in HTML.
1215
1216 Note that with all the above cases, you can determine which type of
1217 "=over" ... "=back" you have, by examining the first (non-"=cut",
1218 non-"=pod") Pod paragraph after the "=over" command.
1219
1220 • Pod formatters must tolerate arbitrarily large amounts of text in
1221 the "=item text..." paragraph. In practice, most such paragraphs
1222 are short, as in:
1223
1224 =item For cutting off our trade with all parts of the world
1225
1226 But they may be arbitrarily long:
1227
1228 =item For transporting us beyond seas to be tried for pretended
1229 offenses
1230
1231 =item He is at this time transporting large armies of foreign
1232 mercenaries to complete the works of death, desolation and
1233 tyranny, already begun with circumstances of cruelty and perfidy
1234 scarcely paralleled in the most barbarous ages, and totally
1235 unworthy the head of a civilized nation.
1236
1237 • Pod processors should tolerate "=item *" / "=item number" commands
1238 with no accompanying paragraph. The middle item is an example:
1239
1240 =over
1241
1242 =item 1
1243
1244 Pick up dry cleaning.
1245
1246 =item 2
1247
1248 =item 3
1249
1250 Stop by the store. Get Abba Zabas, Stoli, and cheap lawn chairs.
1251
1252 =back
1253
1254 • No "=over" ... "=back" region can contain headings. Processors may
1255 treat such a heading as an error.
1256
1257 • Note that an "=over" ... "=back" region should have some content.
1258 That is, authors should not have an empty region like this:
1259
1260 =over
1261
1262 =back
1263
1264 Pod processors seeing such a contentless "=over" ... "=back"
1265 region, may ignore it, or may report it as an error.
1266
1267 • Processors must tolerate an "=over" list that goes off the end of
1268 the document (i.e., which has no matching "=back"), but they may
1269 warn about such a list.
1270
1271 • Authors of Pod formatters should note that this construct:
1272
1273 =item Neque
1274
1275 =item Porro
1276
1277 =item Quisquam Est
1278
1279 Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1280 velit, sed quia non numquam eius modi tempora incidunt ut
1281 labore et dolore magnam aliquam quaerat voluptatem.
1282
1283 =item Ut Enim
1284
1285 is semantically ambiguous, in a way that makes formatting decisions
1286 a bit difficult. On the one hand, it could be mention of an item
1287 "Neque", mention of another item "Porro", and mention of another
1288 item "Quisquam Est", with just the last one requiring the
1289 explanatory paragraph "Qui dolorem ipsum quia dolor..."; and then
1290 an item "Ut Enim". In that case, you'd want to format it like so:
1291
1292 Neque
1293
1294 Porro
1295
1296 Quisquam Est
1297 Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1298 velit, sed quia non numquam eius modi tempora incidunt ut
1299 labore et dolore magnam aliquam quaerat voluptatem.
1300
1301 Ut Enim
1302
1303 But it could equally well be a discussion of three (related or
1304 equivalent) items, "Neque", "Porro", and "Quisquam Est", followed
1305 by a paragraph explaining them all, and then a new item "Ut Enim".
1306 In that case, you'd probably want to format it like so:
1307
1308 Neque
1309 Porro
1310 Quisquam Est
1311 Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1312 velit, sed quia non numquam eius modi tempora incidunt ut
1313 labore et dolore magnam aliquam quaerat voluptatem.
1314
1315 Ut Enim
1316
1317 But (for the foreseeable future), Pod does not provide any way for
1318 Pod authors to distinguish which grouping is meant by the above
1319 "=item"-cluster structure. So formatters should format it like so:
1320
1321 Neque
1322
1323 Porro
1324
1325 Quisquam Est
1326
1327 Qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
1328 velit, sed quia non numquam eius modi tempora incidunt ut
1329 labore et dolore magnam aliquam quaerat voluptatem.
1330
1331 Ut Enim
1332
1333 That is, there should be (at least roughly) equal spacing between
1334 items as between paragraphs (although that spacing may well be less
1335 than the full height of a line of text). This leaves it to the
1336 reader to use (con)textual cues to figure out whether the "Qui
1337 dolorem ipsum..." paragraph applies to the "Quisquam Est" item or
1338 to all three items "Neque", "Porro", and "Quisquam Est". While not
1339 an ideal situation, this is preferable to providing formatting cues
1340 that may be actually contrary to the author's intent.
1341
1343 Data paragraphs are typically used for inlining non-Pod data that is to
1344 be used (typically passed through) when rendering the document to a
1345 specific format:
1346
1347 =begin rtf
1348
1349 \par{\pard\qr\sa4500{\i Printed\~\chdate\~\chtime}\par}
1350
1351 =end rtf
1352
1353 The exact same effect could, incidentally, be achieved with a single
1354 "=for" paragraph:
1355
1356 =for rtf \par{\pard\qr\sa4500{\i Printed\~\chdate\~\chtime}\par}
1357
1358 (Although that is not formally a data paragraph, it has the same
1359 meaning as one, and Pod parsers may parse it as one.)
1360
1361 Another example of a data paragraph:
1362
1363 =begin html
1364
1365 I like <em>PIE</em>!
1366
1367 <hr>Especially pecan pie!
1368
1369 =end html
1370
1371 If these were ordinary paragraphs, the Pod parser would try to expand
1372 the "E</em>" (in the first paragraph) as a formatting code, just like
1373 "E<lt>" or "E<eacute>". But since this is in a "=begin
1374 identifier"..."=end identifier" region and the identifier "html"
1375 doesn't begin have a ":" prefix, the contents of this region are stored
1376 as data paragraphs, instead of being processed as ordinary paragraphs
1377 (or if they began with a spaces and/or tabs, as verbatim paragraphs).
1378
1379 As a further example: At time of writing, no "biblio" identifier is
1380 supported, but suppose some processor were written to recognize it as a
1381 way of (say) denoting a bibliographic reference (necessarily containing
1382 formatting codes in ordinary paragraphs). The fact that "biblio"
1383 paragraphs were meant for ordinary processing would be indicated by
1384 prefacing each "biblio" identifier with a colon:
1385
1386 =begin :biblio
1387
1388 Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
1389 Programs.> Prentice-Hall, Englewood Cliffs, NJ.
1390
1391 =end :biblio
1392
1393 This would signal to the parser that paragraphs in this begin...end
1394 region are subject to normal handling as ordinary/verbatim paragraphs
1395 (while still tagged as meant only for processors that understand the
1396 "biblio" identifier). The same effect could be had with:
1397
1398 =for :biblio
1399 Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
1400 Programs.> Prentice-Hall, Englewood Cliffs, NJ.
1401
1402 The ":" on these identifiers means simply "process this stuff normally,
1403 even though the result will be for some special target". I suggest
1404 that parser APIs report "biblio" as the target identifier, but also
1405 report that it had a ":" prefix. (And similarly, with the above
1406 "html", report "html" as the target identifier, and note the lack of a
1407 ":" prefix.)
1408
1409 Note that a "=begin identifier"..."=end identifier" region where
1410 identifier begins with a colon, can contain commands. For example:
1411
1412 =begin :biblio
1413
1414 Wirth's classic is available in several editions, including:
1415
1416 =for comment
1417 hm, check abebooks.com for how much used copies cost.
1418
1419 =over
1420
1421 =item
1422
1423 Wirth, Niklaus. 1975. I<Algorithmen und Datenstrukturen.>
1424 Teubner, Stuttgart. [Yes, it's in German.]
1425
1426 =item
1427
1428 Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
1429 Programs.> Prentice-Hall, Englewood Cliffs, NJ.
1430
1431 =back
1432
1433 =end :biblio
1434
1435 Note, however, a "=begin identifier"..."=end identifier" region where
1436 identifier does not begin with a colon, should not directly contain
1437 "=head1" ... "=head4" commands, nor "=over", nor "=back", nor "=item".
1438 For example, this may be considered invalid:
1439
1440 =begin somedata
1441
1442 This is a data paragraph.
1443
1444 =head1 Don't do this!
1445
1446 This is a data paragraph too.
1447
1448 =end somedata
1449
1450 A Pod processor may signal that the above (specifically the "=head1"
1451 paragraph) is an error. Note, however, that the following should not
1452 be treated as an error:
1453
1454 =begin somedata
1455
1456 This is a data paragraph.
1457
1458 =cut
1459
1460 # Yup, this isn't Pod anymore.
1461 sub excl { (rand() > .5) ? "hoo!" : "hah!" }
1462
1463 =pod
1464
1465 This is a data paragraph too.
1466
1467 =end somedata
1468
1469 And this too is valid:
1470
1471 =begin someformat
1472
1473 This is a data paragraph.
1474
1475 And this is a data paragraph.
1476
1477 =begin someotherformat
1478
1479 This is a data paragraph too.
1480
1481 And this is a data paragraph too.
1482
1483 =begin :yetanotherformat
1484
1485 =head2 This is a command paragraph!
1486
1487 This is an ordinary paragraph!
1488
1489 And this is a verbatim paragraph!
1490
1491 =end :yetanotherformat
1492
1493 =end someotherformat
1494
1495 Another data paragraph!
1496
1497 =end someformat
1498
1499 The contents of the above "=begin :yetanotherformat" ... "=end
1500 :yetanotherformat" region aren't data paragraphs, because the
1501 immediately containing region's identifier (":yetanotherformat") begins
1502 with a colon. In practice, most regions that contain data paragraphs
1503 will contain only data paragraphs; however, the above nesting is
1504 syntactically valid as Pod, even if it is rare. However, the handlers
1505 for some formats, like "html", will accept only data paragraphs, not
1506 nested regions; and they may complain if they see (targeted for them)
1507 nested regions, or commands, other than "=end", "=pod", and "=cut".
1508
1509 Also consider this valid structure:
1510
1511 =begin :biblio
1512
1513 Wirth's classic is available in several editions, including:
1514
1515 =over
1516
1517 =item
1518
1519 Wirth, Niklaus. 1975. I<Algorithmen und Datenstrukturen.>
1520 Teubner, Stuttgart. [Yes, it's in German.]
1521
1522 =item
1523
1524 Wirth, Niklaus. 1976. I<Algorithms + Data Structures =
1525 Programs.> Prentice-Hall, Englewood Cliffs, NJ.
1526
1527 =back
1528
1529 Buy buy buy!
1530
1531 =begin html
1532
1533 <img src='wirth_spokesmodeling_book.png'>
1534
1535 <hr>
1536
1537 =end html
1538
1539 Now now now!
1540
1541 =end :biblio
1542
1543 There, the "=begin html"..."=end html" region is nested inside the
1544 larger "=begin :biblio"..."=end :biblio" region. Note that the content
1545 of the "=begin html"..."=end html" region is data paragraph(s), because
1546 the immediately containing region's identifier ("html") doesn't begin
1547 with a colon.
1548
1549 Pod parsers, when processing a series of data paragraphs one after
1550 another (within a single region), should consider them to be one large
1551 data paragraph that happens to contain blank lines. So the content of
1552 the above "=begin html"..."=end html" may be stored as two data
1553 paragraphs (one consisting of "<img
1554 src='wirth_spokesmodeling_book.png'>\n" and another consisting of
1555 "<hr>\n"), but should be stored as a single data paragraph (consisting
1556 of "<img src='wirth_spokesmodeling_book.png'>\n\n<hr>\n").
1557
1558 Pod processors should tolerate empty "=begin something"..."=end
1559 something" regions, empty "=begin :something"..."=end :something"
1560 regions, and contentless "=for something" and "=for :something"
1561 paragraphs. I.e., these should be tolerated:
1562
1563 =for html
1564
1565 =begin html
1566
1567 =end html
1568
1569 =begin :biblio
1570
1571 =end :biblio
1572
1573 Incidentally, note that there's no easy way to express a data paragraph
1574 starting with something that looks like a command. Consider:
1575
1576 =begin stuff
1577
1578 =shazbot
1579
1580 =end stuff
1581
1582 There, "=shazbot" will be parsed as a Pod command "shazbot", not as a
1583 data paragraph "=shazbot\n". However, you can express a data paragraph
1584 consisting of "=shazbot\n" using this code:
1585
1586 =for stuff =shazbot
1587
1588 The situation where this is necessary, is presumably quite rare.
1589
1590 Note that =end commands must match the currently open =begin command.
1591 That is, they must properly nest. For example, this is valid:
1592
1593 =begin outer
1594
1595 X
1596
1597 =begin inner
1598
1599 Y
1600
1601 =end inner
1602
1603 Z
1604
1605 =end outer
1606
1607 while this is invalid:
1608
1609 =begin outer
1610
1611 X
1612
1613 =begin inner
1614
1615 Y
1616
1617 =end outer
1618
1619 Z
1620
1621 =end inner
1622
1623 This latter is improper because when the "=end outer" command is seen,
1624 the currently open region has the formatname "inner", not "outer". (It
1625 just happens that "outer" is the format name of a higher-up region.)
1626 This is an error. Processors must by default report this as an error,
1627 and may halt processing the document containing that error. A
1628 corollary of this is that regions cannot "overlap". That is, the latter
1629 block above does not represent a region called "outer" which contains X
1630 and Y, overlapping a region called "inner" which contains Y and Z. But
1631 because it is invalid (as all apparently overlapping regions would be),
1632 it doesn't represent that, or anything at all.
1633
1634 Similarly, this is invalid:
1635
1636 =begin thing
1637
1638 =end hting
1639
1640 This is an error because the region is opened by "thing", and the
1641 "=end" tries to close "hting" [sic].
1642
1643 This is also invalid:
1644
1645 =begin thing
1646
1647 =end
1648
1649 This is invalid because every "=end" command must have a formatname
1650 parameter.
1651
1653 perlpod, "PODs: Embedded Documentation" in perlsyn, podchecker
1654
1656 Sean M. Burke
1657
1658
1659
1660perl v5.34.1 2022-03-15 PERLPODSPEC(1)