POD2-RU
view release on metacpan or search on metacpan
lib/POD2/RU/perlpodspec.pod view on Meta::CPAN
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
paragraphs are data paragraphs. But if "formatname" I<does> begin
with a colon, then non-command paragraphs are ordinary paragraphs
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/>. 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"
This marks the end of the region opened by the matching
"=begin formatname" region. If "formatname" is not the formatname
of the most recent open "=begin formatname" region, then this
is an error, and must generate an error message. This
is discussed in detail in the section
L</About Data Paragraphs and "=beginE<sol>=end" Regions>.
=item "=for formatname text..."
This is synonymous with:
=begin formatname
text...
=end formatname
That is, it creates a region consisting of a single paragraph; that
paragraph is to be treated as a normal paragraph if "formatname"
begins with a ":"; if "formatname" I<doesn't> begin with a colon,
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
above (like "=head", or "=haed1", or "=stuff", or "=cuttlefish",
or "=w123"), that processor must by default treat this as an
error. It must not process the paragraph beginning with that
command, must by default warn of this as an error, and may
abort the parse. A Pod parser may allow a way for particular
applications to add to the above list of known commands, and to
stipulate, for each additional command, whether formatting
codes should be processed.
Future versions of this specification may add additional
commands.
=head1 Pod Formatting Codes
(Note that in previous drafts of this document and of perlpod,
formatting codes were referred to as "interior sequences", and
this term may still be found in the documentation for Pod parsers,
and in error messages from Pod processors.)
There are two syntaxes for formatting codes:
=over
=item *
A formatting code starts with a capital letter (just US-ASCII [A-Z])
followed by a "<", any number of characters, and ending with the first
matching ">". Examples:
That's what I<you> think!
What's C<dump()> for?
X<C<chmod> and C<unlink()> Under Different Operating Systems>
=item *
A formatting code starts with a capital letter (just US-ASCII [A-Z])
followed by two or more "<"'s, one or more whitespace characters,
any number of characters, one or more whitespace characters,
and ending with the first matching sequence of two or more ">"'s, where
the number of ">"'s equals the number of "<"'s in the opening of this
formatting code. Examples:
That's what I<< you >> think!
C<<< open(X, ">>thing.dat") || die $! >>>
B<< $foo->bar(); >>
With this syntax, the whitespace character(s) after the "CE<lt><<"
and before the ">>" (or whatever letter) are I<not> renderable. They
do not signify whitespace, are merely part of the formatting codes
themselves. That is, these are all synonymous:
lib/POD2/RU/perlpodspec.pod view on Meta::CPAN
...must I<not> be parsed as two paragraphs in italics (with the I
code starting in one paragraph and starting in another.) Instead,
the first paragraph should generate a warning, but that aside, the
above code must parse as if it were:
I<I told you not to do this!>
Don't make me say it again!E<gt>
(In SGMLish jargon, all Pod commands are like block-level
elements, whereas all Pod formatting codes are like inline-level
elements.)
=head1 Notes on Implementing Pod Processors
The following is a long section of miscellaneous requirements
and suggestions to do with Pod processing.
=over
=item *
Pod formatters should tolerate lines in verbatim blocks that are of
any length, even if that means having to break them (possibly several
times, for very long lines) to avoid text running off the side of the
page. Pod formatters may warn of such line-breaking. Such warnings
are particularly appropriate for lines are over 100 characters long, which
are usually not intentional.
=item *
Pod parsers must recognize I<all> of the three well-known newline
formats: CR, LF, and CRLF. See L<perlport|perlport>.
=item *
Pod parsers should accept input lines that are of any length.
=item *
Since Perl recognizes a Unicode Byte Order Mark at the start of files
as signaling that the file is Unicode encoded as in UTF-16 (whether
big-endian or little-endian) or UTF-8, Pod parsers should do the
same. Otherwise, the character encoding should be understood as
being UTF-8 if the first highbit byte sequence in the file seems
valid as a UTF-8 sequence, or otherwise as Latin-1.
Future versions of this specification may specify
how Pod can accept other encodings. Presumably treatment of other
encodings in Pod parsing would be as in XML parsing: whatever the
encoding declared by a particular Pod file, content is to be
stored in memory as Unicode characters.
=item *
The well known Unicode Byte Order Marks are as follows: if the
file begins with the two literal byte values 0xFE 0xFF, this is
the BOM for big-endian UTF-16. If the file begins with the two
literal byte value 0xFF 0xFE, this is the BOM for little-endian
UTF-16. If the file begins with the three literal byte values
0xEF 0xBB 0xBF, this is the BOM for UTF-8.
=for comment
use bytes; print map sprintf(" 0x%02X", ord $_), split '', "\x{feff}";
0xEF 0xBB 0xBF
=for comment
If toke.c is modified to support UTF-32, add mention of those here.
=item *
A naive but sufficient heuristic for testing the first highbit
byte-sequence in a BOM-less file (whether in code or in Pod!), to see
whether that sequence is valid as UTF-8 (RFC 2279) is to check whether
that the first byte in the sequence is in the range 0xC0 - 0xFD
I<and> whether the next byte is in the range
0x80 - 0xBF. If so, the parser may conclude that this file is in
UTF-8, and all highbit sequences in the file should be assumed to
be UTF-8. Otherwise the parser should treat the file as being
in Latin-1. In the unlikely circumstance that the first highbit
sequence in a truly non-UTF-8 file happens to appear to be UTF-8, one
can cater to our heuristic (as well as any more intelligent heuristic)
by prefacing that line with a comment line containing a highbit
sequence that is clearly I<not> valid as UTF-8. A line consisting
of simply "#", an e-acute, and any non-highbit byte,
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 PerlIO layer?), we can presumably delete
mention of these icky details from this file, and can instead
tell people to just use appropriate class/layer.
Auto-recognition of newline sequences would be another desirable
feature of such a class/layer.
HINT HINT HINT.
=for comment
"The probability that a string of characters
in any other encoding appears as valid UTF-8 is low" - RFC2279
=item *
This document's requirements and suggestions about encodings
do not apply to Pod processors running on non-ASCII platforms,
notably EBCDIC platforms.
=item *
Pod processors must treat a "=for [label] [content...]" paragraph as
meaning the same thing as a "=begin [label]" paragraph, content, and
an "=end [label]" paragraph. (The parser may conflate these two
constructs, or may leave them distinct, in the expectation that the
formatter will nevertheless treat them the same.)
=item *
When rendering Pod to a format that allows comments (i.e., to nearly
any format other than plaintext), a Pod formatter must insert comment
text identifying its name and version number, and the name and
version numbers of any modules it might be using to process the Pod.
Minimal examples:
%% POD::Pod2PS v3.14159, using POD::Parser v1.92
<!-- Pod::HTML v3.14159, using POD::Parser v1.92 -->
{\doccomm generated by Pod::Tree::RTF 3.14159 using Pod::Tree 1.08}
.\" Pod::Man version 3.14159, using POD::Parser version 1.92
Formatters may also insert additional comments, including: the
release date of the Pod formatter program, the contact address for
the author(s) of the formatter, the current time, the name of input
( run in 1.013 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )