Debian Codegraph @

upstream/opensuse-tumbleweed/man1/perlpodspec.1

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