perlpodspec.html
来自「perl教程」· HTML 代码 · 共 1,304 行 · 第 1/5 页
HTML
1,304 行
point. That is, it normally renders as nothing, but may render as a
"-" if a formatter breaks the word at that point. Pod formatters
should, as appropriate, do one of the following: 1) render this with
a code with the same meaning (e.g., "\-" in RTF), 2) pass it through
in the expectation that the formatter understands this character as
such, or 3) delete it.</p>
<p>For example:</p>
<pre>
sigE<shy>action
manuE<shy>script
JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi</pre>
<p>These signal to a formatter that if it is to hyphenate "sigaction"
or "manuscript", then it should be done as
"sig-<em>[linebreak]</em>action" or "manu-<em>[linebreak]</em>script"
(and if it doesn't hyphenate it, then the <code>E<shy></code> doesn't
show up at all). And if it is
to hyphenate "Jarkko" and/or "Hietaniemi", it can do
so only at the points where there is a <code>E<shy></code> code.</p>
<p>In practice, it is anticipated that this character will not be used
often, but formatters should either support it, or delete it.</p>
</li>
<li>
<p>If you think that you want to add a new command to Pod (like, say, a
"=biblio" command), consider whether you could get the same
effect with a for or begin/end sequence: "=for biblio ..." or "=begin
biblio" ... "=end biblio". Pod processors that don't understand
"=for biblio", etc, will simply ignore it, whereas they may complain
loudly if they see "=biblio".</p>
</li>
<li>
<p>Throughout this document, "Pod" has been the preferred spelling for
the name of the documentation format. One may also use "POD" or
"pod". For the documentation that is (typically) in the Pod
format, you may use "pod", or "Pod", or "POD". Understanding these
distinctions is useful; but obsessing over how to spell them, usually
is not.</p>
</li>
</ul>
<p>
</p>
<hr />
<h1><a name="about_l______codes">About L<...> Codes</a></h1>
<p>As you can tell from a glance at <a href="../../lib/Pod/perlpod.html">perlpod</a>, the L<...>
code is the most complex of the Pod formatting codes. The points below
will hopefully clarify what it means and how processors should deal
with it.</p>
<ul>
<li>
<p>In parsing an L<...> code, Pod parsers must distinguish at least
four attributes:</p>
<dl>
<dt><strong><a name="item_first_3a">First:</a></strong>
<dd>
<p>The link-text. If there is none, this must be undef. (E.g., in
"L<Perl Functions|perlfunc>", the link-text is "Perl Functions".
In "L<Time::HiRes>" and even "L<|Time::HiRes>", there is no
link text. Note that link text may contain formatting.)</p>
</dd>
</li>
<dt><strong><a name="item_second_3a">Second:</a></strong>
<dd>
<p>The possibly inferred link-text -- i.e., if there was no real link
text, then this is the text that we'll infer in its place. (E.g., for
"L<Getopt::Std>", the inferred link text is "Getopt::Std".)</p>
</dd>
</li>
<dt><strong><a name="item_third_3a">Third:</a></strong>
<dd>
<p>The name or URL, or undef if none. (E.g., in "L<Perl
Functions|perlfunc>", the name -- also sometimes called the page --
is "perlfunc". In "L</CAVEATS>", the name is undef.)</p>
</dd>
</li>
<dt><strong><a name="item_fourth_3a">Fourth:</a></strong>
<dd>
<p>The section (AKA "item" in older perlpods), or undef if none. E.g.,
in <a href="../../lib/Getopt/Std.html#description">DESCRIPTION in the Getopt::Std manpage</a>, "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".)</p>
</dd>
</li>
</dl>
<p>Pod parsers may also note additional attributes including:</p>
<dl>
<dt><strong><a name="item_fifth_3a">Fifth:</a></strong>
<dd>
<p>A flag for whether item 3 (if present) is a URL (like
"http://lists.perl.org" is), in which case there should be no section
attribute; a Pod name (like "perldoc" and "Getopt::Std" are); or
possibly a man page name (like "crontab(5)" is).</p>
</dd>
</li>
<dt><strong><a name="item_sixth_3a">Sixth:</a></strong>
<dd>
<p>The raw original L<...> content, before text is split on
"|", "/", etc, and before E<...> codes are expanded.</p>
</dd>
</li>
</dl>
<p>(The above were numbered only for concise reference below. It is not
a requirement that these be passed as an actual list or array.)</p>
<p>For example:</p>
<pre>
L<Foo::Bar>
=> undef, # link text
"Foo::Bar", # possibly inferred link text
"Foo::Bar", # name
undef, # section
'pod', # what sort of link
"Foo::Bar" # original content</pre>
<pre>
L<Perlport's section on NL's|<a href="../../lib/Pod/perlport.html">perlport</a>/Newlines>
=> "Perlport's section on NL's", # link text
"Perlport's section on NL's", # possibly inferred link text
"<a href="../../lib/Pod/perlport.html">perlport</a>", # name
"Newlines", # section
'pod', # what sort of link
"Perlport's section on NL's|<a href="../../lib/Pod/perlport.html">perlport</a>/Newlines" # orig. content</pre>
<pre>
L<<a href="../../lib/Pod/perlport.html">perlport</a>/Newlines>
=> undef, # link text
'"Newlines" in <a href="../../lib/Pod/perlport.html">perlport</a>', # possibly inferred link text
"<a href="../../lib/Pod/perlport.html">perlport</a>", # name
"Newlines", # section
'pod', # what sort of link
"<a href="../../lib/Pod/perlport.html">perlport</a>/Newlines" # original content</pre>
<pre>
L<crontab(5)/"DESCRIPTION">
=> undef, # link text
'"DESCRIPTION" in crontab(5)', # possibly inferred link text
"crontab(5)", # name
"DESCRIPTION", # section
'man', # what sort of link
'crontab(5)/"DESCRIPTION"' # original content</pre>
<pre>
L</Object Attributes>
=> undef, # link text
'"Object Attributes"', # possibly inferred link text
undef, # name
"Object Attributes", # section
'pod', # what sort of link
"/Object Attributes" # original content</pre>
<pre>
L<<a href="http://www.perl.org/>">http://www.perl.org/></a>;
=> undef, # link text
"<a href="http://www.perl.org/"">http://www.perl.org/"</a>;, # possibly inferred link text
"<a href="http://www.perl.org/"">http://www.perl.org/"</a>;, # name
undef, # section
'url', # what sort of link
"<a href="http://www.perl.org/"">http://www.perl.org/"</a>; # original content</pre>
<p>Note that you can distinguish URL-links from anything else by the
fact that they match <a href="../../lib/Pod/perlfunc.html#item_m_"><code>m/\A\w+:[^:\s]\S*\z/</code></a>. So
<code>L<http://www.perl.com></code> is a URL, but
<code>L<HTTP::Response></code> isn't.</p>
<li>
<p>In case of L<...> codes with no "text|" part in them,
older formatters have exhibited great variation in actually displaying
the link or cross reference. For example, L<crontab(5)> would render
as "the <code>crontab(5)</code> manpage", or "in the <code>crontab(5)</code> manpage"
or just "<code>crontab(5)</code>".</p>
<p>Pod processors must now treat "text|"-less links as follows:</p>
<pre>
L<name> => L<name|name>
L</section> => L<"section"|/section>
L<name/section> => L<"section" in name|name/section></pre>
</li>
<li>
<p>Note that section names might contain markup. I.e., if a section
starts with:</p>
<pre>
=head2 About the C<-M> Operator</pre>
<p>or with:</p>
<pre>
=item About the C<-M> Operator</pre>
<p>then a link to it would look like this:</p>
<pre>
L<somedoc/About the C<-M> Operator></pre>
<p>Formatters may choose to ignore the markup for purposes of resolving
the link and use only the renderable characters in the section name,
as in:</p>
<pre>
<h1><a name="About_the_-M_Operator">About the <code>-M</code>
Operator</h1></pre>
<pre>
...</pre>
<pre>
<a href="somedoc#About_the_-M_Operator">About the <code>-M</code>
Operator" in somedoc</a></pre>
</li>
<li>
<p>Previous versions of perlpod distinguished <code>L<name/"section"></code>
links from <code>L<name/item></code> links (and their targets). These
have been merged syntactically and semantically in the current
specification, and <em>section</em> can refer either to a "=head<em>n</em> Heading
Content" command or to a "=item Item Content" command. This
specification does not specify what behavior should be in the case
of a given document having several things all seeming to produce the
same <em>section</em> identifier (e.g., in HTML, several things all producing
the same <em>anchorname</em> in <a name="<em>anchorname</em>">...</a>
elements). Where Pod processors can control this behavior, they should
use the first such anchor. That is, <code>L<Foo/Bar></code> refers to the
<em>first</em> "Bar" section in Foo.</p>
<p>But for some processors/formats this cannot be easily controlled; as
with the HTML example, the behavior of multiple ambiguous
<a name="<em>anchorname</em>">...</a> is most easily just left up to
browsers to decide.</p>
</li>
<li>
<p>Authors wanting to link to a particular (absolute) URL, must do so
only with "L<scheme:...>" codes (like
L<<a href="http://www.perl.org>">http://www.perl.org></a>), and must not attempt "L<Some Site
Name|scheme:...>" codes. This restriction avoids many problems
in parsing and rendering L<...> codes.</p>
</li>
<li>
<p>In a <code>L<text|...></code> code, text may contain formatting codes
for formatting or for E<...> escapes, as in:</p>
<pre>
L<B<ummE<234>stuff>|...></pre>
<p>For <code>L<...></code> codes without a "name|" part, only
<code>E<...></code> and <code>Z<></code> codes may occur -- no
other formatting codes. That is, authors should not use
"<code>L<B<Foo::Bar>></code>".</p>
<p>Note, however, that formatting codes and Z<>'s can occur in any
and all parts of an L<...> (i.e., in <em>name</em>, <em>section</em>, <em>text</em>,
and <em>url</em>).</p>
<p>Authors must not nest L<...> codes. For example, "L<The
L<Foo::Bar> man page>" should be treated as an error.</p>
</li>
<li>
<p>Note that Pod authors may use formatting codes inside the "text"
part of "L<text|name>" (and so on for L<text|/"sec">).</p>
<p>In other words, this is valid:</p>
<pre>
Go read L<the docs on C<$.>|<a href="../../lib/Pod/perlvar.html">perlvar</a>/"$."></pre>
<p>Some output formats that do allow rendering "L<...>" codes as
hypertext, might not allow the link-text to be formatted; in
that case, formatters will have to just ignore that formatting.</p>
</li>
<li>
<p>At time of writing, <code>L<name></code> values are of two types:
either the name of a Pod page like <code>L<Foo::Bar></code> (which
might be a real Perl module or program in an @INC / PATH
directory, or a .pod file in those places); or the name of a UNIX
man page, like <code>L<crontab(5)></code>. In theory, <code>L<chmod></code>
in ambiguous between a Pod page called "chmod", or the Unix man page
"chmod" (in whatever man-section). However, the presence of a string
in parens, as in "crontab(5)", is sufficient to signal that what
is being discussed is not a Pod page, and so is presumably a
UNIX man page. The distinction is of no importance to many
Pod processors, but some processors that render to hypertext formats
may need to distinguish them in order to know how to render a
given <code>L<foo></code
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?