tagset.html

来自「perl教程」· HTML 代码 · 共 266 行

HTML
266 行
字号
<?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>HTML::Tagset - data tables useful in parsing HTML</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>HTML::Tagset - data tables useful in parsing HTML</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

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

		<li><a href="#hashset__html__tagset__emptyelement">hashset %HTML::Tagset::emptyElement</a></li>
		<li><a href="#hashset__html__tagset__optionalendtag">hashset %HTML::Tagset::optionalEndTag</a></li>
		<li><a href="#hash__html__tagset__linkelements">hash %HTML::Tagset::linkElements</a></li>
		<li><a href="#hash__html__tagset__boolean_attr">hash %HTML::Tagset::boolean_attr</a></li>
		<li><a href="#hashset__html__tagset__isphrasemarkup">hashset %HTML::Tagset::isPhraseMarkup</a></li>
		<li><a href="#hashset__html__tagset__is_possible_strict_p_content">hashset %HTML::Tagset::is_Possible_Strict_P_Content</a></li>
		<li><a href="#hashset__html__tagset__isheadelement">hashset %HTML::Tagset::isHeadElement</a></li>
		<li><a href="#hashset__html__tagset__islist">hashset %HTML::Tagset::isList</a></li>
		<li><a href="#hashset__html__tagset__istableelement">hashset %HTML::Tagset::isTableElement</a></li>
		<li><a href="#hashset__html__tagset__isformelement">hashset %HTML::Tagset::isFormElement</a></li>
		<li><a href="#hashset__html__tagset__isbodymarkup">hashset %HTML::Tagset::isBodyMarkup</a></li>
		<li><a href="#hashset__html__tagset__isheadorbodyelement">hashset %HTML::Tagset::isHeadOrBodyElement</a></li>
		<li><a href="#hashset__html__tagset__isknown">hashset %HTML::Tagset::isKnown</a></li>
		<li><a href="#hashset__html__tagset__cantighten">hashset %HTML::Tagset::canTighten</a></li>
		<li><a href="#array__html__tagset__p_closure_barriers">array @HTML::Tagset::p_closure_barriers</a></li>
		<li><a href="#hashset__iscdata_parent">hashset %isCDATA_Parent</a></li>
	</ul>

	<li><a href="#caveats">CAVEATS</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#copyright___license">COPYRIGHT &amp; LICENSE</a></li>
	<li><a href="#acknowledgements">ACKNOWLEDGEMENTS</a></li>
	<li><a href="#author">AUTHOR</a></li>
	<li><a href="#bugs">BUGS</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>HTML::Tagset - data tables useful in parsing HTML</p>
<p>
</p>
<hr />
<h1><a name="version">VERSION</a></h1>
<p>Version 3.10</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
  <span class="keyword">use</span> <span class="variable">HTML::Tagset</span><span class="operator">;</span>
  <span class="comment"># Then use any of the items in the HTML::Tagset package</span>
  <span class="comment">#  as need arises</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module contains several data tables useful in various kinds of
HTML parsing operations.</p>
<p>Note that all tag names used are lowercase.</p>
<p>In the following documentation, a &quot;hashset&quot; is a hash being used as a
set -- the hash conveys that its keys are there, and the actual values
associated with the keys are not significant.  (But what values are
there, are always true.)</p>
<p>
</p>
<hr />
<h1><a name="variables">VARIABLES</a></h1>
<p>Note that none of these variables are exported.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__emptyelement">hashset %HTML::Tagset::emptyElement</a></h2>
<p>This hashset has as values the tag-names (GIs) of elements that cannot
have content.  (For example, &quot;base&quot;, &quot;br&quot;, &quot;hr&quot;.)  So
<code>$HTML::Tagset::emptyElement{'hr'}</code> exists and is true.
<code>$HTML::Tagset::emptyElement{'dl'}</code> does not exist, and so is not true.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__optionalendtag">hashset %HTML::Tagset::optionalEndTag</a></h2>
<p>This hashset lists tag-names for elements that can have content, but whose
end-tags are generally, &quot;safely&quot;, omissible.  Example:
<code>$HTML::Tagset::emptyElement{'li'}</code> exists and is true.</p>
<p>
</p>
<h2><a name="hash__html__tagset__linkelements">hash %HTML::Tagset::linkElements</a></h2>
<p>Values in this hash are tagnames for elements that might contain
links, and the value for each is a reference to an array of the names
of attributes whose values can be links.</p>
<p>
</p>
<h2><a name="hash__html__tagset__boolean_attr">hash %HTML::Tagset::boolean_attr</a></h2>
<p>This hash (not hashset) lists what attributes of what elements can be
printed without showing the value (for example, the &quot;noshade&quot; attribute
of &quot;hr&quot; elements).  For elements with only one such attribute, its value
is simply that attribute name.  For elements with many such attributes,
the value is a reference to a hashset containing all such attributes.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__isphrasemarkup">hashset %HTML::Tagset::isPhraseMarkup</a></h2>
<p>This hashset contains all phrasal-level elements.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__is_possible_strict_p_content">hashset %HTML::Tagset::is_Possible_Strict_P_Content</a></h2>
<p>This hashset contains all phrasal-level elements that be content of a
P element, for a strict model of HTML.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__isheadelement">hashset %HTML::Tagset::isHeadElement</a></h2>
<p>This hashset contains all elements that elements that should be
present only in the 'head' element of an HTML document.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__islist">hashset %HTML::Tagset::isList</a></h2>
<p>This hashset contains all elements that can contain &quot;li&quot; elements.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__istableelement">hashset %HTML::Tagset::isTableElement</a></h2>
<p>This hashset contains all elements that are to be found only in/under
a &quot;table&quot; element.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__isformelement">hashset %HTML::Tagset::isFormElement</a></h2>
<p>This hashset contains all elements that are to be found only in/under
a &quot;form&quot; element.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__isbodymarkup">hashset %HTML::Tagset::isBodyMarkup</a></h2>
<p>This hashset contains all elements that are to be found only in/under
the &quot;body&quot; element of an HTML document.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__isheadorbodyelement">hashset %HTML::Tagset::isHeadOrBodyElement</a></h2>
<p>This hashset includes all elements that I notice can fall either in
the head or in the body.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__isknown">hashset %HTML::Tagset::isKnown</a></h2>
<p>This hashset lists all known HTML elements.</p>
<p>
</p>
<h2><a name="hashset__html__tagset__cantighten">hashset %HTML::Tagset::canTighten</a></h2>
<p>This hashset lists elements that might have ignorable whitespace as
children or siblings.</p>
<p>
</p>
<h2><a name="array__html__tagset__p_closure_barriers">array @HTML::Tagset::p_closure_barriers</a></h2>
<p>This array has a meaning that I have only seen a need for in
<code>HTML::TreeBuilder</code>, but I include it here on the off chance that someone
might find it of use:</p>
<p>When we see a &quot;&lt;p&gt;&quot; token, we go lookup up the lineage for a p
element we might have to minimize.  At first sight, we might say that
if there's a p anywhere in the lineage of this new p, it should be
closed.  But that's wrong.  Consider this document:</p>
<pre>
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;foo&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;p&gt;foo
        &lt;table&gt;
          &lt;tr&gt;
            &lt;td&gt;
               foo
               &lt;p&gt;bar
            &lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;</pre>
<p>The second p is quite legally inside a much higher p.</p>
<p>My formalization of the reason why this is legal, but this:</p>
<pre>
  &lt;p&gt;foo&lt;p&gt;bar&lt;/p&gt;&lt;/p&gt;</pre>
<p>isn't, is that something about the table constitutes a &quot;barrier&quot; to
the application of the rule about what p must minimize.</p>
<p>So <code>@HTML::Tagset::p_closure_barriers</code> is the list of all such
barrier-tags.</p>
<p>
</p>
<h2><a name="hashset__iscdata_parent">hashset %isCDATA_Parent</a></h2>
<p>This hashset includes all elements whose content is CDATA.</p>
<p>
</p>
<hr />
<h1><a name="caveats">CAVEATS</a></h1>
<p>You may find it useful to alter the behavior of modules (like
<code>HTML::Element</code> or <code>HTML::TreeBuilder</code>) that use <code>HTML::Tagset</code>'s
data tables by altering the data tables themselves.  You are welcome
to try, but be careful; and be aware that different modules may or may
react differently to the data tables being changed.</p>
<p>Note that it may be inappropriate to use these tables for <em>producing</em>
HTML -- for example, <code>%isHeadOrBodyElement</code> lists the tagnames
for all elements that can appear either in the head or in the body,
such as &quot;script&quot;.  That doesn't mean that I am saying your code that
produces HTML should feel free to put script elements in either place!
If you are producing programs that spit out HTML, you should be
<em>intimately</em> familiar with the DTDs for HTML or XHTML (available at
<code>http://www.w3.org/</code>), and you should slavishly obey them, not
the data tables in this document.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/HTML/Element.html">the HTML::Element manpage</a>, <a href="../../lib/HTML/TreeBuilder.html">the HTML::TreeBuilder manpage</a>, <a href="../../lib/HTML/LinkExtor.html">the HTML::LinkExtor manpage</a></p>
<p>
</p>
<hr />
<h1><a name="copyright___license">COPYRIGHT &amp; LICENSE</a></h1>
<p>Copyright 1995-2000 Gisle Aas.</p>
<p>Copyright 2000-2005 Sean M. Burke.</p>
<p>Copyright 2005 Andy Lester.</p>
<p>This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.</p>
<p>
</p>
<hr />
<h1><a name="acknowledgements">ACKNOWLEDGEMENTS</a></h1>
<p>Most of the code/data in this module was adapted from code written
by Gisle Aas for <code>HTML::Element</code>, <code>HTML::TreeBuilder</code>, and
<code>HTML::LinkExtor</code>.  Then it was maintained by Sean M. Burke.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Current maintainer: Andy Lester, <code>&lt;andy at petdance.com&gt;</code></p>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>Please report any bugs or feature requests to
<code>bug-html-tagset at rt.cpan.org</code>, or through the web interface at
<a href="http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Tagset">http://rt.cpan.org/NoAuth/ReportBug.html</a>.  I will
be notified, and then you'll automatically be notified of progress on
your bug as I make changes.</p>

</body>

</html>

⌨️ 快捷键说明

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