pretty.html

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

HTML
141 行
字号
<?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>CGI::Pretty - module to produce nicely formatted HTML code</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>CGI::Pretty - module to produce nicely formatted HTML code</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="#tags_that_won_t_be_formatted">Tags that won't be formatted</a></li>
		<li><a href="#customizing_the_indenting">Customizing the Indenting</a></li>
	</ul>

	<li><a href="#bugs">BUGS</a></li>
	<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>CGI::Pretty - module to produce nicely formatted HTML code</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
    <span class="keyword">use</span> <span class="variable">CGI::Pretty</span> <span class="string">qw( :html3 )</span><span class="operator">;</span>
</pre>
<pre>
    <span class="comment"># Print a table with a single data element</span>
    <span class="keyword">print</span> <span class="variable">table</span><span class="operator">(</span> <span class="variable">TR</span><span class="operator">(</span> <span class="variable">td</span><span class="operator">(</span> <span class="string">"foo"</span> <span class="operator">)</span> <span class="operator">)</span> <span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>CGI::Pretty is a module that derives from CGI.  It's sole function is to
allow users of CGI to output nicely formatted HTML code.</p>
<p>When using the CGI module, the following code:
    print table( TR( td( &quot;foo&quot; ) ) );</p>
<p>produces the following output:
    &lt;TABLE&gt;&lt;TR&gt;&lt;TD&gt;foo&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;</p>
<p>If a user were to create a table consisting of many rows and many columns,
the resultant HTML code would be quite difficult to read since it has no
carriage returns or indentation.</p>
<p>CGI::Pretty fixes this problem.  What it does is add a carriage
return and indentation to the HTML code so that one can easily read
it.</p>
<pre>
    <span class="keyword">print</span> <span class="variable">table</span><span class="operator">(</span> <span class="variable">TR</span><span class="operator">(</span> <span class="variable">td</span><span class="operator">(</span> <span class="string">"foo"</span> <span class="operator">)</span> <span class="operator">)</span> <span class="operator">);</span>
</pre>
<p>now produces the following output:
    &lt;TABLE&gt;
       &lt;TR&gt;
          &lt;TD&gt;
             foo
          &lt;/TD&gt;
       &lt;/TR&gt;
    &lt;/TABLE&gt;</p>
<p>
</p>
<h2><a name="tags_that_won_t_be_formatted">Tags that won't be formatted</a></h2>
<p>The &lt;A&gt; and &lt;PRE&gt; tags are not formatted.  If these tags were formatted, the
user would see the extra indentation on the web browser causing the page to
look different than what would be expected.  If you wish to add more tags to
the list of tags that are not to be touched, push them onto the <code>@AS_IS</code> array:</p>
<pre>
    <span class="keyword">push</span> <span class="variable">@CGI::Pretty::AS_IS</span><span class="operator">,</span><span class="string">qw(CODE XMP)</span><span class="operator">;</span>
</pre>
<p>
</p>
<h2><a name="customizing_the_indenting">Customizing the Indenting</a></h2>
<p>If you wish to have your own personal style of indenting, you can change the
<code>$INDENT</code> variable:</p>
<pre>
    <span class="variable">$CGI::Pretty::INDENT</span> <span class="operator">=</span> <span class="string">"\t\t"</span><span class="operator">;</span>
</pre>
<p>would cause the indents to be two tabs.</p>
<p>Similarly, if you wish to have more space between lines, you may change the
<code>$LINEBREAK</code> variable:</p>
<pre>
    <span class="variable">$CGI::Pretty::LINEBREAK</span> <span class="operator">=</span> <span class="string">"\n\n"</span><span class="operator">;</span>
</pre>
<p>would create two carriage returns between lines.</p>
<p>If you decide you want to use the regular CGI indenting, you can easily do 
the following:</p>
<pre>
    <span class="variable">$CGI::Pretty::INDENT</span> <span class="operator">=</span> <span class="variable">$CGI::Pretty::LINEBREAK</span> <span class="operator">=</span> <span class="string">""</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>This section intentionally left blank.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Brian Paulsen &lt;<a href="mailto:Brian@ThePaulsens.com">Brian@ThePaulsens.com</a>&gt;, with minor modifications by
Lincoln Stein &lt;<a href="mailto:lstein@cshl.org">lstein@cshl.org</a>&gt; for incorporation into the CGI.pm
distribution.</p>
<p>Copyright 1999, Brian Paulsen.  All rights reserved.</p>
<p>This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.</p>
<p>Bug reports and comments to <a href="mailto:Brian@ThePaulsens.com.">Brian@ThePaulsens.com.</a>  You can also write
to <a href="mailto:lstein@cshl.org,">lstein@cshl.org,</a> but this code looks pretty hairy to me and I'm not
sure I understand it!</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/CGI.html">the CGI manpage</a></p>

</body>

</html>

⌨️ 快捷键说明

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