perlpodspec.html
来自「perl教程」· HTML 代码 · 共 1,304 行 · 第 1/5 页
HTML
1,304 行
that case, the Pod processor must halt parsing of the input file, and
must by default emit a warning.</p>
</dd>
</li>
<dt><strong><a name="item__22_3dover_22">"=over"</a></strong>
<dd>
<p>This command indicates that this is the start of a list/indent
region. If there is any text following the "=over", it must consist
of only a nonzero positive numeral. The semantics of this numeral is
explained in the <a href="#about__over____back_regions">About =over...=back Regions</a> section, further
below. Formatting codes are not expanded. Examples:</p>
</dd>
<dd>
<pre>
=over 3</pre>
</dd>
<dd>
<pre>
=over 3.5</pre>
</dd>
<dd>
<pre>
=over</pre>
</dd>
</li>
<dt><strong><a name="item__22_3ditem_22">"=item"</a></strong>
<dd>
<p>This command indicates that an item in a list begins here. Formatting
codes are processed. The semantics of the (optional) text in the
remainder of this paragraph are
explained in the <a href="#about__over____back_regions">About =over...=back Regions</a> section, further
below. Examples:</p>
</dd>
<dd>
<pre>
=item</pre>
</dd>
<dd>
<pre>
=item *</pre>
</dd>
<dd>
<pre>
=item *</pre>
</dd>
<dd>
<pre>
=item 14</pre>
</dd>
<dd>
<pre>
=item 3.</pre>
</dd>
<dd>
<pre>
=item C<< $thing->stuff(I<dodad>) >></pre>
</dd>
<dd>
<pre>
=item For transporting us beyond seas to be tried for pretended
offenses</pre>
</dd>
<dd>
<pre>
=item He is at this time transporting large armies of foreign
mercenaries to complete the works of death, desolation and
tyranny, already begun with circumstances of cruelty and perfidy
scarcely paralleled in the most barbarous ages, and totally
unworthy the head of a civilized nation.</pre>
</dd>
</li>
<dt><strong><a name="item__22_3dback_22">"=back"</a></strong>
<dd>
<p>This command indicates that this is the end of the region begun
by the most recent "=over" command. It permits no text after the
"=back" command.</p>
</dd>
</li>
<dt><strong><a name="item__22_3dbegin_formatname_22">"=begin formatname"</a></strong>
<dd>
<p>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" <em>does</em> begin
with a colon, then non-command paragraphs are ordinary paragraphs
or data paragraphs. This is discussed in detail in the section
<a href="#about_data_paragraphs_and__begine_sol__end_regions">About Data Paragraphs and "=begin/=end" Regions</a>.</p>
</dd>
<dd>
<p>It is advised that formatnames match the regexp
<a href="../../lib/Pod/perlfunc.html#item_m_"><code>m/\A:?[-a-zA-Z0-9_]+\z/</code></a>. Implementors should anticipate future
expansion in the semantics and syntax of the first parameter
to "=begin"/"=end"/"=for".</p>
</dd>
</li>
<dt><strong><a name="item__22_3dend_formatname_22">"=end formatname"</a></strong>
<dd>
<p>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
<a href="#about_data_paragraphs_and__begine_sol__end_regions">About Data Paragraphs and "=begin/=end" Regions</a>.</p>
</dd>
</li>
<dt><strong><a name="item__22_3dfor_formatname_text_2e_2e_2e_22">"=for formatname text..."</a></strong>
<dd>
<p>This is synonymous with:</p>
</dd>
<dd>
<pre>
=begin formatname</pre>
</dd>
<dd>
<pre>
text...</pre>
</dd>
<dd>
<pre>
=end formatname</pre>
</dd>
<dd>
<p>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" <em>doesn't</em> 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.</p>
</dd>
</li>
<dt><strong><a name="item__22_3dencoding_encodingname_22">"=encoding encodingname"</a></strong>
<dd>
<p>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 <em>encodingname</em>, which must be
an encoding name that <a href="../../lib/Encode/Encoding.html">the Encoding manpage</a> recognizes. (Encoding's list
of supported encodings, in <a href="../../Encoding/Supported.html">the Encoding::Supported manpage</a>, is useful here.)
If the Pod parser cannot decode the declared encoding, it
should emit a warning and may abort parsing the document
altogether.</p>
</dd>
<dd>
<p>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 "=use utf8" line, and later on
another "=use 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).</p>
</dd>
</li>
</dl>
<p>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.</p>
<p>Future versions of this specification may add additional
commands.</p>
<p>
</p>
<hr />
<h1><a name="pod_formatting_codes">Pod Formatting Codes</a></h1>
<p>(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.)</p>
<p>There are two syntaxes for formatting codes:</p>
<ul>
<li>
<p>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:</p>
<pre>
That's what I<you> think!</pre>
<pre>
What's C<dump()> for?</pre>
<pre>
X<C<chmod> and C<unlink()> Under Different Operating Systems></pre>
</li>
<li>
<p>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:</p>
<pre>
That's what I<< you >> think!</pre>
<pre>
C<<< open(X, ">>thing.dat") || die $! >>></pre>
<pre>
<span class="variable">B</span><span class="operator"><<</span> <span class="variable">$foo</span><span class="operator">-></span><span class="variable">bar</span><span class="operator">();</span> <span class="operator">>></span>
</pre>
<p>With this syntax, the whitespace <code>character(s)</code> after the "C<<<"
and before the ">>" (or whatever letter) are <em>not</em> renderable -- they
do not signify whitespace, are merely part of the formatting codes
themselves. That is, these are all synonymous:</p>
<pre>
C<thing>
C<< thing >>
C<< thing >>
C<<< thing >>>
C<<<<
thing
>>>></pre>
<p>and so on.</p>
</li>
</ul>
<p>In parsing Pod, a notably tricky part is the correct parsing of
(potentially nested!) formatting codes. Implementors should
consult the code in the <code>parse_text</code> routine in Pod::Parser as an
example of a correct implementation.</p>
<dl>
<dt><strong><a name="item_i_3ctext_3e__2d_2d_italic_text"><code>I<text></code> -- italic text</a></strong>
<dd>
<p>See the brief discussion in <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_b_3ctext_3e__2d_2d_bold_text"><code>B<text></code> -- bold text</a></strong>
<dd>
<p>See the brief discussion in <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_c_3ccode_3e__2d_2d_code_text"><code>C<code></code> -- code text</a></strong>
<dd>
<p>See the brief discussion in <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_f_3cfilename_3e__2d_2d_style_for_filenames"><code>F<filename></code> -- style for filenames</a></strong>
<dd>
<p>See the brief discussion in <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_x_3ctopic_name_3e__2d_2d_an_index_entry"><code>X<topic name></code> -- an index entry</a></strong>
<dd>
<p>See the brief discussion in <a href="../../lib/Pod/perlpod.html#formatting_codes">Formatting Codes in the perlpod manpage</a>.</p>
</dd>
<dd>
<p>This code is unusual in that most formatters completely discard
this code and its content. Other formatters will render it with
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?