A mechanism for inlineable OP equivalents of XSUBs is a TODO.
[p5sagit/p5-mst-13.2.git] / pod / perlpodspec.pod
index 145309c..7ab5659 100644 (file)
@@ -65,7 +65,7 @@ directly formatting it).  A B<Pod formatter> (or B<Pod translator>)
 is a module or program that converts Pod to some other format (HTML,
 plaintext, TeX, PostScript, RTF).  A B<Pod processor> might be a
 formatter or translator, or might be a program that does something
-else with the Pod (like wordcounting it, scanning for index points,
+else with the Pod (like counting words, scanning for index points,
 etc.).
 
 Pod content is contained in B<Pod blocks>.  A Pod block starts with a
@@ -189,7 +189,7 @@ is a verbatim paragraph, because its first line starts with a literal
 whitespace character (and there's no "=begin"..."=end" region around).
 
 The "=begin I<identifier>" ... "=end I<identifier>" commands stop
-paragraphs that they surround from being parsed as data or verbatim
+paragraphs that they surround from being parsed as ordinary or verbatim
 paragraphs, if I<identifier> doesn't begin with a colon.  This
 is discussed in detail in the section
 L</About Data Paragraphs and "=beginE<sol>=end" Regions>.
@@ -238,7 +238,7 @@ ignored.  Examples:
   # This is the first line of program text.
   sub foo { # This is the second.
 
-It is an error to try to I<start> a Pod black with a "=cut" command.  In
+It is an error to try to I<start> a Pod block with a "=cut" command.  In
 that case, the Pod processor must halt parsing of the input file, and
 must by default emit a warning.
 
@@ -293,6 +293,8 @@ by the most recent "=over" command.  It permits no text after the
 
 =item "=begin formatname"
 
+=item "=begin formatname parameter"
+
 This marks the following paragraphs (until the matching "=end
 formatname") as being for some special kind of processing.  Unless
 "formatname" begins with a colon, the contained non-command
@@ -302,9 +304,11 @@ or data paragraphs.  This is discussed in detail in the section
 L</About Data Paragraphs and "=beginE<sol>=end" Regions>.
 
 It is advised that formatnames match the regexp
-C<m/\A:?[-a-zA-Z0-9_]+\z/>.  Implementors should anticipate future
-expansion in the semantics and syntax of the first parameter
-to "=begin"/"=end"/"=for".
+C<m/\A:?[−a−zA−Z0−9_]+\z/>.  Everything following whitespace after the
+formatname is a parameter that may be used by the formatter when dealing
+with this region.  This parameter must not be repeated in the "=end"
+paragraph.  Implementors should anticipate future expansion in the
+semantics and syntax of the first parameter to "=begin"/"=end"/"=for".
 
 =item "=end formatname"
 
@@ -332,6 +336,29 @@ then "text..." will constitute a data paragraph.  There is no way
 to use "=for formatname text..." to express "text..." as a verbatim
 paragraph.
 
+=item "=encoding encodingname"
+
+This command, which should occur early in the document (at least
+before any non-US-ASCII data!), declares that this document is
+encoded in the encoding I<encodingname>, which must be
+an encoding name that L<Encode> recognizes.  (Encode's list
+of supported encodings, in L<Encode::Supported>, is useful here.)
+If the Pod parser cannot decode the declared encoding, it 
+should emit a warning and may abort parsing the document
+altogether.
+
+A document having more than one "=encoding" line should be
+considered an error.  Pod processors may silently tolerate this if
+the not-first "=encoding" lines are just duplicates of the
+first one (e.g., if there's a "=encoding utf8" line, and later on
+another "=encoding utf8" line).  But Pod processors should complain if
+there are contradictory "=encoding" lines in the same document
+(e.g., if there is a "=encoding utf8" early in the document and
+"=encoding big5" later).  Pod processors that recognize BOMs
+may also complain if they see an "=encoding" line
+that contradicts the BOM (e.g., if a document with a UTF-16LE
+BOM has an "=encoding shiftjis" line).
+
 =back
 
 If a Pod processor sees any command other than the ones listed
@@ -463,7 +490,7 @@ L</Notes on Implementing Pod Processors>.
 
 This formatting code is syntactically simple, but semantically
 complex.  What it means is that each space in the printable
-content of this code signifies a nonbreaking space.
+content of this code signifies a non-breaking space.
 
 Consider:
 
@@ -474,7 +501,7 @@ Consider:
 Both signify the monospace (c[ode] style) text consisting of
 "$x", one space, "?", one space, ":", one space, "$z".  The
 difference is that in the latter, with the S code, those spaces
-are not "normal" spaces, but instead are nonbreaking spaces.
+are not "normal" spaces, but instead are non-breaking spaces.
 
 =back
 
@@ -499,7 +526,7 @@ a "-".  This was so that this:
 
 would parse as equivalent to this:
 
-    C<$foo-E<lt>bar>
+    C<$foo-E<gt>bar>
 
 instead of as equivalent to a "C" formatting code containing 
 only "$foo-", and then a "bar>" outside the "C" formatting code.  This
@@ -589,7 +616,7 @@ UTF-16.  If the file begins with the three literal byte values
  0xEF 0xBB 0xBF
 
 =for comment
- If toke.c is modified to support UTF32, add mention of those here.
+ If toke.c is modified to support UTF-32, add mention of those here.
 
 =item *
 
@@ -611,11 +638,11 @@ is sufficient to establish this file's encoding.
 
 =for comment
  If/WHEN some brave soul makes these heuristics into a generic
- text-file class (or file discipline?), we can presumably delete
+ text-file class (or PerlIO layer?), we can presumably delete
  mention of these icky details from this file, and can instead
- tell people to just use appropriate class/discipline.
+ tell people to just use appropriate class/layer.
  Auto-recognition of newline sequences would be another desirable
- feature of such a class/discipline.
+ feature of such a class/layer.
  HINT HINT HINT.
 
 =for comment
@@ -701,7 +728,7 @@ period-space-space or period-newline sequences).
 Pod parsers should not, by default, try to coerce apostrophe (') and
 quote (") into smart quotes (little 9's, 66's, 99's, etc), nor try to
 turn backtick (`) into anything else but a single backtick character
-(distinct from an openquote character!), nor "--" into anything but
+(distinct from an open quote character!), nor "--" into anything but
 two minus signs.  They I<must never> do any of those things to text
 in CE<lt>...> formatting codes, and never I<ever> to text in verbatim
 paragraphs.
@@ -709,10 +736,10 @@ paragraphs.
 =item *
 
 When rendering Pod to a format that has two kinds of hyphens (-), one
-that's a nonbreaking hyphen, and another that's a breakable hyphen
+that's a non-breaking hyphen, and another that's a breakable hyphen
 (as in "object-oriented", which can be split across lines as
 "object-", newline, "oriented"), formatters are encouraged to
-generally translate "-" to nonbreaking hyphen, but may apply
+generally translate "-" to non-breaking hyphen, but may apply
 heuristics to convert some of these to breaking hyphens.
 
 =item *
@@ -883,9 +910,9 @@ character) to the escape sequences or codes necessary for conveying
 such sequences in the target output format.  A converter to *roff
 would, for example know that "\xE9" (whether conveyed literally, or via
 a EE<lt>...> sequence) is to be conveyed as "e\\*'".
-Similarly, a program rendering Pod in a MacOS application window, would
+Similarly, a program rendering Pod in a Mac OS application window, would
 presumably need to know that "\xE9" maps to codepoint 142 in MacRoman
-encoding that (at time of writing) is native for MacOS.  Such
+encoding that (at time of writing) is native for Mac OS.  Such
 Unicode2whatever mappings are presumably already widely available for
 common output formats.  (Such mappings may be incomplete!  Implementers
 are not expected to bend over backwards in an attempt to render
@@ -936,7 +963,7 @@ for idiosyncratic mappings of Unicode-to-I<my_escapes>.
 
 =item *
 
-It is up to individual Pod formatter to display good judgment when
+It is up to individual Pod formatter to display good judgement when
 confronted with an unrenderable character (which is distinct from an
 unknown EE<lt>thing> sequence that the parser couldn't resolve to
 anything, renderable or not).  It is good practice to map Latin letters
@@ -969,15 +996,15 @@ EE<lt>euro>1,000,000 Solution|Million::Euros>".
 
 =item *
 
-Some Pod formatters output to formats that implement nonbreaking
+Some Pod formatters output to formats that implement non-breaking
 spaces as an individual character (which I'll call "NBSP"), and
-others output to formats that implement nonbreaking spaces just as
+others output to formats that implement non-breaking spaces just as
 spaces wrapped in a "don't break this across lines" code.  Note that
 at the level of Pod, both sorts of codes can occur: Pod can contain a
 NBSP character (whether as a literal, or as a "EE<lt>160>" or
 "EE<lt>nbsp>" code); and Pod can contain "SE<lt>foo
 IE<lt>barE<gt> baz>" codes, where "mere spaces" (character 32) in
-such codes are taken to represent nonbreaking spaces.  Pod
+such codes are taken to represent non-breaking spaces.  Pod
 parsers should consider supporting the optional parsing of "SE<lt>foo
 IE<lt>barE<gt> baz>" as if it were
 "fooI<NBSP>IE<lt>barE<gt>I<NBSP>baz", and, going the other way, the
@@ -1107,7 +1134,7 @@ is "perlfunc".  In "LE<lt>/CAVEATS>", the name is undef.)
 =item Fourth:
 
 The section (AKA "item" in older perlpods), or undef if none.  E.g.,
-in L<Getopt::Std/DESCRIPTION>, "DESCRIPTION" is the section.  (Note
+in "LE<lt>Getopt::Std/DESCRIPTIONE<gt>", "DESCRIPTION" is the section.  (Note
 that this is not the same as a manpage section like the "5" in "man 5
 crontab".  "Section Foo" in the Pod sense means the part of the text
 that's introduced by the heading or item whose text is "Foo".)
@@ -1185,6 +1212,14 @@ For example:
         'url',                          # what sort of link
         "http://www.perl.org/"          # original content
 
+  L<Perl.org|http://www.perl.org/>
+    =>  "Perl.org",                     # link text
+        "http://www.perl.org/",         # possibly inferred link text
+        "http://www.perl.org/",         # name
+        undef,                          # section
+        'url',                          # what sort of link
+        "Perl.org|http://www.perl.org/" # original content
+
 Note that you can distinguish URL-links from anything else by the
 fact that they match C<m/\A\w+:[^:\s]\S*\z/>.  So
 C<LE<lt>http://www.perl.comE<gt>> is a URL, but
@@ -1309,15 +1344,16 @@ given C<LE<lt>fooE<gt>> code.
 
 =item *
 
-Previous versions of perlpod allowed for a C<LE<lt>sectionE<gt>> syntax
-(as in "C<LE<lt>Object AttributesE<gt>>"), which was not easily distinguishable
-from C<LE<lt>nameE<gt>> syntax.  This syntax is no longer in the
-specification, and has been replaced by the C<LE<lt>"section"E<gt>> syntax
-(where the quotes were formerly optional).  Pod parsers should tolerate
-the C<LE<lt>sectionE<gt>> syntax, for a while at least.  The suggested
-heuristic for distinguishing C<LE<lt>sectionE<gt>> from C<LE<lt>nameE<gt>>
-is that if it contains any whitespace, it's a I<section>.  Pod processors
-may warn about this being deprecated syntax.
+Previous versions of perlpod allowed for a C<LE<lt>sectionE<gt>> syntax (as in
+C<LE<lt>Object AttributesE<gt>>), which was not easily distinguishable from
+C<LE<lt>nameE<gt>> syntax and for C<LE<lt>"section"E<gt>> which was only
+slightly less ambiguous.  This syntax is no longer in the specification, and
+has been replaced by the C<LE<lt>/sectionE<gt>> syntax (where the slash was
+formerly optional).  Pod parsers should tolerate the C<LE<lt>"section"E<gt>>
+syntax, for a while at least.  The suggested heuristic for distinguishing
+C<LE<lt>sectionE<gt>> from C<LE<lt>nameE<gt>> is that if it contains any
+whitespace, it's a I<section>.  Pod processors should warn about this being
+deprecated syntax.
 
 =back
 
@@ -1518,7 +1554,7 @@ probably want to format it like so:
 
   Ut Enim
 
-But (for the forseeable future), Pod does not provide any way for Pod
+But (for the foreseeable future), Pod does not provide any way for Pod
 authors to distinguish which grouping is meant by the above
 "=item"-cluster structure.  So formatters should format it like so: