parseutils.html

来自「perl教程」· HTML 代码 · 共 388 行 · 第 1/2 页

HTML
388
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Pod::ParseUtils - helpers for POD parsing and conversion</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>Pod::ParseUtils - helpers for POD parsing and conversion</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#pod__list">Pod::List</a></li>
		<li><a href="#pod__hyperlink">Pod::Hyperlink</a></li>
		<li><a href="#pod__cache">Pod::Cache</a></li>
		<li><a href="#pod__cache__item">Pod::Cache::Item</a></li>
	</ul>

	<li><a href="#author">AUTHOR</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Pod::ParseUtils - helpers for POD parsing and conversion</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
  <span class="keyword">use</span> <span class="variable">Pod::ParseUtils</span><span class="operator">;</span>
</pre>
<pre>
  <span class="keyword">my</span> <span class="variable">$list</span> <span class="operator">=</span> <span class="variable">new</span> <span class="variable">Pod::List</span><span class="operator">;</span>
  <span class="keyword">my</span> <span class="variable">$link</span> <span class="operator">=</span> <span class="variable">Pod::Hyperlink</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">'Pod::Parser'</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><strong>Pod::ParseUtils</strong> contains a few object-oriented helper packages for
POD parsing and processing (i.e. in POD formatters and translators).</p>
<p>
</p>
<h2><a name="pod__list">Pod::List</a></h2>
<p><strong>Pod::List</strong> can be used to hold information about POD lists
(written as =over ... =item ... =back) for further processing.
The following methods are available:</p>
<dl>
<dt><strong><a name="item_new">Pod::List-&gt;<code>new()</code></a></strong>

<dd>
<p>Create a new list object. Properties may be specified through a hash
reference like this:</p>
</dd>
<dd>
<pre>
  <span class="keyword">my</span> <span class="variable">$list</span> <span class="operator">=</span> <span class="variable">Pod::List</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="operator">{</span> <span class="string">-start</span> <span class="operator">=&gt;</span> <span class="variable">$.</span><span class="operator">,</span> <span class="string">-indent</span> <span class="operator">=&gt;</span> <span class="number">4</span> <span class="operator">}</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<p>See the individual methods/properties for details.</p>
</dd>
</li>
<dt><strong><a name="item_file">$list-&gt;<code>file()</code></a></strong>

<dd>
<p>Without argument, retrieves the file name the list is in. This must
have been set before by either specifying <strong>-file</strong> in the <strong>new()</strong>
method or by calling the <strong>file()</strong> method with a scalar argument.</p>
</dd>
</li>
<dt><strong><a name="item_start">$list-&gt;<code>start()</code></a></strong>

<dd>
<p>Without argument, retrieves the line number where the list started.
This must have been set before by either specifying <strong>-start</strong> in the
<strong>new()</strong> method or by calling the <strong>start()</strong> method with a scalar
argument.</p>
</dd>
</li>
<dt><strong><a name="item_indent">$list-&gt;<code>indent()</code></a></strong>

<dd>
<p>Without argument, retrieves the indent level of the list as specified
in <code>=over n</code>. This must have been set before by either specifying
<strong>-indent</strong> in the <strong>new()</strong> method or by calling the <strong>indent()</strong> method
with a scalar argument.</p>
</dd>
</li>
<dt><strong><a name="item_type">$list-&gt;<code>type()</code></a></strong>

<dd>
<p>Without argument, retrieves the list type, which can be an arbitrary value,
e.g. <code>OL</code>, <code>UL</code>, ... when thinking the HTML way.
This must have been set before by either specifying
<strong>-type</strong> in the <strong>new()</strong> method or by calling the <strong>type()</strong> method
with a scalar argument.</p>
</dd>
</li>
<dt><strong><a name="item_rx">$list-&gt;<code>rx()</code></a></strong>

<dd>
<p>Without argument, retrieves a regular expression for simplifying the 
individual item strings once the list type has been determined. Usage:
E.g. when converting to HTML, one might strip the leading number in
an ordered list as <code>&lt;OL&gt;</code> already prints numbers itself.
This must have been set before by either specifying
<strong>-rx</strong> in the <strong>new()</strong> method or by calling the <strong>rx()</strong> method
with a scalar argument.</p>
</dd>
</li>
<dt><strong><a name="item_item">$list-&gt;<code>item()</code></a></strong>

<dd>
<p>Without argument, retrieves the array of the items in this list.
The items may be represented by any scalar.
If an argument has been given, it is pushed on the list of items.</p>
</dd>
</li>
<dt><strong><a name="item_parent">$list-&gt;<code>parent()</code></a></strong>

<dd>
<p>Without argument, retrieves information about the parent holding this
list, which is represented as an arbitrary scalar.
This must have been set before by either specifying
<strong>-parent</strong> in the <strong>new()</strong> method or by calling the <strong>parent()</strong> method
with a scalar argument.</p>
</dd>
</li>
<dt><strong><a name="item_tag">$list-&gt;<code>tag()</code></a></strong>

<dd>
<p>Without argument, retrieves information about the list tag, which can be
any scalar.
This must have been set before by either specifying
<strong>-tag</strong> in the <strong>new()</strong> method or by calling the <strong>tag()</strong> method
with a scalar argument.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="pod__hyperlink">Pod::Hyperlink</a></h2>
<p><strong>Pod::Hyperlink</strong> is a class for manipulation of POD hyperlinks. Usage:</p>
<pre>
  <span class="keyword">my</span> <span class="variable">$link</span> <span class="operator">=</span> <span class="variable">Pod::Hyperlink</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">'alternative text|page/"section in page"'</span><span class="operator">);</span>
</pre>
<p>The <strong>Pod::Hyperlink</strong> class is mainly designed to parse the contents of the
<code>L&lt;...&gt;</code> sequence, providing a simple interface for accessing the
different parts of a POD hyperlink for further processing. It can also be
used to construct hyperlinks.</p>
<dl>
<dt><strong>Pod::Hyperlink-&gt;<code>new()</code></strong>

<dd>
<p>The <strong>new()</strong> method can either be passed a set of key/value pairs or a single
scalar value, namely the contents of a <code>L&lt;...&gt;</code> sequence. An object
of the class <code>Pod::Hyperlink</code> is returned. The value <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> indicates a
failure, the error message is stored in <a href="../../lib/Pod/perlvar.html#item___"><code>$@</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_parse">$link-&gt;<code>parse($string)</code></a></strong>

<dd>
<p>This method can be used to (re)parse a (new) hyperlink, i.e. the contents
of a <code>L&lt;...&gt;</code> sequence. The result is stored in the current object.
Warnings are stored in the <strong>warnings</strong> property.
E.g. sections like <a href="../../lib/Pod/perlfunc.html#item_open"><code>L&lt;open(2)&gt;</code></a> are deprecated, as they do not point
to Perl documents. <code>L&lt;DBI::foo(3p)&gt;</code> is wrong as well, the manpage
section can simply be dropped.</p>
</dd>
</li>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?