perlpodspec.html
来自「perl教程」· HTML 代码 · 共 1,304 行 · 第 1/5 页
HTML
1,304 行
invisible codes that can be used in building an index of
the current document.</p>
</dd>
</li>
<dt><strong><a name="item_null"><code>Z<></code> -- a null (zero-effect) formatting code</a></strong>
<dd>
<p>Discussed briefly in <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>.</p>
</dd>
<dd>
<p>This code is unusual is that it should have no content. That is,
a processor may complain if it sees <code>Z<potatoes></code>. Whether
or not it complains, the <em>potatoes</em> text should ignored.</p>
</dd>
</li>
<dt><strong><a name="item_l_3cname_3e__2d_2d_a_hyperlink"><code>L<name></code> -- a hyperlink</a></strong>
<dd>
<p>The complicated syntaxes of this code are discussed at length in
<a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>, and implementation details are
discussed below, in <a href="#about_le_lt____e_gt__codes">About L<...> Codes</a>. Parsing the
contents of L<content> is tricky. Notably, the content has to be
checked for whether it looks like a URL, or whether it has to be split
on literal "|" and/or "/" (in the right order!), and so on,
<em>before</em> E<...> codes are resolved.</p>
</dd>
</li>
<dt><strong><a name="item_e_3cescape_3e__2d_2d_a_character_escape"><code>E<escape></code> -- a character escape</a></strong>
<dd>
<p>See <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>, and several points in
<a href="#notes_on_implementing_pod_processors">Notes on Implementing Pod Processors</a>.</p>
</dd>
</li>
<dt><strong><a name="item_s_3ctext_3e__2d_2d_text_contains_non_2dbreaking_sp"><code>S<text></code> -- text contains non-breaking spaces</a></strong>
<dd>
<p>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 non-breaking space.</p>
</dd>
<dd>
<p>Consider:</p>
</dd>
<dd>
<pre>
C<$x ? $y : $z></pre>
</dd>
<dd>
<pre>
S<C<$x ? $y : $z>></pre>
</dd>
<dd>
<p>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 non-breaking spaces.</p>
</dd>
</li>
</dl>
<p>If a Pod processor sees any formatting code other than the ones
listed above (as in "N<...>", or "Q<...>", etc.), that
processor must by default treat this as an error.
A Pod parser may allow a way for particular
applications to add to the above list of known formatting codes;
a Pod parser might even allow a way to stipulate, for each additional
command, whether it requires some form of special processing, as
L<...> does.</p>
<p>Future versions of this specification may add additional
formatting codes.</p>
<p>Historical note: A few older Pod processors would not see a ">" as
closing a "C<" code, if the ">" was immediately preceded by
a "-". This was so that this:</p>
<pre>
C<$foo->bar></pre>
<p>would parse as equivalent to this:</p>
<pre>
C<$foo-E<gt>bar></pre>
<p>instead of as equivalent to a "C" formatting code containing
only "$foo-", and then a "bar>" outside the "C" formatting code. This
problem has since been solved by the addition of syntaxes like this:</p>
<pre>
C<< $foo->bar >></pre>
<p>Compliant parsers must not treat "->" as special.</p>
<p>Formatting codes absolutely cannot span paragraphs. If a code is
opened in one paragraph, and no closing code is found by the end of
that paragraph, the Pod parser must close that formatting code,
and should complain (as in "Unterminated I code in the paragraph
starting at line 123: 'Time objects are not...'"). So these
two paragraphs:</p>
<pre>
I<I told you not to do this!</pre>
<pre>
Don't make me say it again!></pre>
<p>...must <em>not</em> 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:</p>
<pre>
I<I told you not to do this!></pre>
<pre>
Don't make me say it again!E<gt></pre>
<p>(In SGMLish jargon, all Pod commands are like block-level
elements, whereas all Pod formatting codes are like inline-level
elements.)</p>
<p>
</p>
<hr />
<h1><a name="notes_on_implementing_pod_processors">Notes on Implementing Pod Processors</a></h1>
<p>The following is a long section of miscellaneous requirements
and suggestions to do with Pod processing.</p>
<ul>
<li>
<p>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.</p>
</li>
<li>
<p>Pod parsers must recognize <em>all</em> of the three well-known newline
formats: CR, LF, and CRLF. See <a href="../../lib/Pod/perlport.html">perlport</a>.</p>
</li>
<li>
<p>Pod parsers should accept input lines that are of any length.</p>
</li>
<li>
<p>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.</p>
<p>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.</p>
</li>
<li>
<p>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.</p>
</li>
<li>
<p>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
<em>and</em> 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 <em>not</em> 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.</p>
</li>
<li>
<p>This document's requirements and suggestions about encodings
do not apply to Pod processors running on non-ASCII platforms,
notably EBCDIC platforms.</p>
</li>
<li>
<p>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.)</p>
</li>
<li>
<p>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:</p>
<pre>
%% POD::Pod2PS v3.14159, using POD::Parser v1.92</pre>
<pre>
<!-- Pod::HTML v3.14159, using POD::Parser v1.92 --></pre>
<pre>
<span class="operator">{\</span><span class="variable">doccomm</span> <span class="variable">generated</span> <span class="variable">by</span> <span class="variable">Pod::Tree::RTF</span> <span class="number">3.14159</span> <span class="variable">using</span> <span class="variable">Pod::Tree</span> <span class="number">1.08</span><span class="operator">}</span>
</pre>
<pre>
.\" Pod::Man version 3.14159, using POD::Parser version 1.92</pre>
<p>Formatters may also insert additional comments, including: the
release date of the Pod formatter program, the contact address for
the <code>author(s)</code> of the formatter, the current time, the name of input
file, the formatting options in effect, version of Perl used, etc.</p>
<p>Formatters may also choose to note errors/warnings as comments,
besides or instead of emitting them otherwise (as in messages to
STDERR, or <a href="../../lib/Pod/perlfunc.html#item_die"><code>die</code></a>ing).</p>
</li>
<li>
<p>Pod parsers <em>may</em> emit warnings or error messages ("Unknown E code
E<zslig>!") to STDERR (whether through printing to STDERR, or
<a href="../../lib/Pod/perlfunc.html#item_warn"><code>warn</code></a>ing/<code>carp</code>ing, or <a href="../../lib/Pod/perlfunc.html#item_die"><code>die</code></a>ing/<code>croak</code>ing), but <em>must</em> allow
suppressing all such STDERR output, and instead allow an option for
reporting errors/warnings
in some other way, whether by triggering a callback, or noting errors
in some attribute of the document object, or some similarly unobtrusive
mechanism -- or even by appending a "Pod Errors" section to the end of
the parsed form of the document.</p>
</li>
<li>
<p>In cases of exceptionally aberrant documents, Pod parsers may abort the
parse. Even then, using <a href="../../lib/Pod/perlfunc.html#item_die"><code>die</code></a>ing/<code>croak</code>ing is to be avoided; where
possible, the parser library may simply close the input file
and add text like "*** Formatting Aborted ***" to the end of the
(partial) in-memory document.</p>
</li>
<li>
<p>In paragraphs where formatting codes (like E<...>, B<...>)
are understood (i.e., <em>not</em> verbatim paragraphs, but <em>including</em>
ordinary paragraphs, and command paragraphs that produce renderable
text, like "=head1"), literal whitespace should generally be considered
"insignificant", in that one literal space has the same meaning as any
(nonzero) number of literal spaces, literal newlines, and literal tabs
(as long as this produces no blank lines, since those would terminate
the paragraph). Pod parsers should compact literal whitespace in each
processed paragraph, but may provide an option for overriding this
(since some processing tasks do not require it), or may follow
additional special rules (for example, specially treating
period-space-space or period-newline sequences).</p>
</li>
<li>
<p>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
two minus signs. They <em>must never</em> do any of those things to text
in C<...> formatting codes, and never <em>ever</em> to text in verbatim
paragraphs.</p>
</li>
<li>
<p>When rendering Pod to a format that has two kinds of hyphens (-), one
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 non-breaking hyphen, but may apply
heuristics to convert some of these to breaking hyphens.</p>
</li>
<li>
<p>Pod formatters should make reasonable efforts to keep words of Perl
code from being broken across lines. For example, "Foo::Bar" in some
formatting systems is seen as eligible for being broken across lines
as "Foo::" newline "Bar" or even "Foo::-" newline "Bar". This should
be avoided where possible, either by disabling all line-breaking in
mid-word, or by wrapping particular words with internal punctuation
in "don't break this across lines" codes (which in some formats may
not be a single code, but might be a matter of inserting non-breaking
zero-width spaces between every pair of characters in a word.)</p>
</li>
<li>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?