123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="utf-8" lang="utf-8">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
- <title>排版类 - CodeIgniter 中文手册|用户手册|用户指南|Wiki文档</title>
- <link rel="shortcut icon" href="http://codeigniter.org.cn/user_guide/../images/design/favicon.ico" type="image/x-icon" />
- <link rel="stylesheet" type="text/css" media="all" href="../userguide.css" />
- <link rel="search" href="http://codeigniter.org.cn/user_guide/../CodeIgniterSearch.xml" type="application/opensearchdescription+xml" title="CodeIgniter 搜索"/>
- <link rel="canonical" href="http://codeigniter.org.cn/user_guide/libraries/typography.html" />
- <script type="text/javascript" src="../nav/mootools.js-ver=20130324.js"></script>
- <script type="text/javascript" src="../nav/mootools-more.js-ver=20130324.js"></script>
- <script type="text/javascript" src="../nav/nav.js-ver=20130324.js"></script>
- <script type="text/javascript" src="../nav/user_guide_menu.js-ver=20130324.js"></script>
- <meta name="robots" content="all" />
- <meta name="author" content="ExpressionEngine Dev Team" />
- <meta name="description" content="CodeIgniter 中文手册, CodeIgniter 用户指南, CodeIgniter User Guide, Wiki 文档" />
- </head>
- <body>
- <!-- START NAVIGATION -->
- <div id="nav">
- <div id="nav_inner">
- <script type="text/javascript">create_menu('../');</script>
- </div>
- </div>
- <script type="text/javascript">_setNavigation();</script>
- <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="切换目录" alt="切换目录" /></a></div>
- <div id="masthead" class="clearfix">
- <div class="topbar-hd"><h1>CodeIgniter 用户指南 版本 2.2.0</h1></div>
- <div class="topbar-tip">编辑文档、查看近期更改请 <a href="#">登录</a> 或 <a href="#">注册</a> <a href="#">找回密码</a></div> <div id="breadcrumb_right"><a href="../toc.html">目录页</a></div>
- </div>
- <!-- END NAVIGATION -->
- <!-- START BREADCRUMB -->
- <table cellpadding="0" cellspacing="0" border="0" style="width:100%">
- <tr>
- <td id="breadcrumb">
- <a href="#" target="_blank">CodeIgniter 中国首页</a> ›
- <a href="../index.html">用户指南首页</a> › 排版类 </td>
- <td id="searchbox">
- <form method="get" action="http://www.google.com.hk/search" target="google_window">
- <input type="hidden" name="client" value="pub-0176846097796333"></input>
- <input type="hidden" name="forid" value="1"></input>
- <input type="hidden" name="ie" value="UTF-8"></input>
- <input type="hidden" name="oe" value="UTF-8"></input>
- <input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.org.cn/user_guide/" />
- 搜索用户指南
- <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />
-
- <input type="submit" class="submit" name="sa" value="Go" />
- </form>
- </td>
- </tr>
- </table>
- <!-- END BREADCRUMB -->
- <div style="clear:both;text-align:right;padding: 6px 40px 0 0;">
- <a href="#" target="_blank">查看原文</a>
- </div>
- <!--<br clear="all" />--><!-- START CONTENT -->
- <div id="content">
- <h1>排版类</h1>
- <p>排版类提供帮助你格式化文本的函数。</p>
- <h2>初始化排版类</h2>
- <p>和CI中的其他类一样, 排版类也需要在控制器中这样用 <dfn>$this->load->library</dfn> 方法初始化:</p>
- <code>$this->load->library('typography');</code>
- <p>一旦被加载, 排版类的对象就可以这样使用: <dfn>$this->typography</dfn></p>
- <h2>auto_typography()</h2>
- <p>格式化文本以便纠正语义和印刷的错误HTML代码。输入一个字符串输出如下的格式化文本:</p>
- <ul>
- <li>用一对P标签包住段落(看起来像是用两个换行符把段落分隔开似的)。</li>
- <li>除了出现 <pre> 标签外,所有的单个换行符被转换为 <br />。</li>
- <li>块级别的元素,如<div>标签,没有被段落包装,但是如果他们包含段落的话就会包含文本。</li>
- <li>除了出现在标签中的引号外,引号会被转换成正确的实体。</li>
- <li>撇号“'”被转换为相应的实体。</li>
- <li>双破折号 (像 -- 或--) 被转换成 em—破折号.</li>
- <li>三个连续的点也会被转换为省略号…</li>
- <li>句子后连续的多个空格将被转换为&nbsp;以便在网页中显示。</li>
- </ul>
- <p>例如:</p>
- <code>$string = $this->typography->auto_typography($string);</code>
- <h3>参数</h3>
- <p>有一个可选参数:布尔值 <kbd>TRUE</kbd> 或 <kbd>FALSE</kbd>决定是否对超过两个的换行进行压缩,减少到两行。</p>
- <p>默认不压缩. 也就是说, 如果这个参数不设置, 它将如下工作:</p>
- <code>$string = $this->typography->auto_typography($string, <kbd>FALSE</kbd>);</code>
- <p class="important"><strong>提示:</strong> 排版格式化可以处理密集数据, 特别是你有很多内容需要格式化处理。如果你选择这个函数处理,你可以考虑<a href="../general/caching.html">缓存</a>你的网页。</p>
- <h2>format_characters()</h2>
- <p>This function is similar to the <dfn>auto_typography</dfn> function above, except that it only does character conversion:</p>
- <p><strong>试翻译:</strong>此函数与上面出现的<dfn>auto_typography</dfn>函数类似, 唯一不同的是此函数仅对以下字符进行转换:</p>
- <ul>
- <li>Quotes are converted to correctly facing curly quote entities, except those that appear within tags.</li>
- <li><strong>试翻译:</strong>除了在标签中的引号外,其他引号将被转换成字符实体.</li>
- <li>Apostrophes are converted to curly apostrophe entities.</li>
- <li><strong>试翻译:</strong>省略号将被转换成正确的格式.</li>
- <li>Double dashes (either like -- this or like--this) are converted to em—dashes.</li>
- <li><strong>试翻译:</strong>双破折号(比如 -- 或--) 将被转换成 em—符号.</li>
- <li>Three consecutive periods either preceding or following a word are converted to ellipsis…</li>
- <li><strong>试翻译:</strong>任何位置(词前或词后)的三个连续点号将被转换成省略号…</li>
- <li>Double spaces following sentences are converted to non-breaking spaces to mimic double spacing.</li>
- <li><strong>试翻译:</strong>句末的双空格将被转换成看似双空格的一个整体符号.</li>
- </ul>
- <p>Usage example:</p>
- <p><strong>试翻译:</strong> 例子:</p>
- <code>$string = $this->typography->format_characters($string);</code>
- <h2>nl2br_except_pre()</h2>
- <p>Converts newlines to <br /> tags unless they appear within <pre> tags.
- This function is identical to the native PHP <dfn>nl2br()</dfn> function, except that it ignores <pre> tags.</p>
- <p><strong>试翻译:</strong> 除了 <pre> 标签内的新行,将被转换为 <br /> 标签.
- 除了本函(方法)数支持 <pre> 标签外, 其与PHP内置函数 <dfn>nl2br()</dfn> 相同.</p>
- <p>Usage example:</p>
- <p><strong>试翻译:</strong>例子:</p>
- <code>$string = $this->typography->nl2br_except_pre($string);</code>
- <h2>protect_braced_quotes</h2>
- <p>When using the Typography library in conjunction with the Template Parser library it can often be desirable to protect single
- and double quotes within curly braces. To enable this, set the <kbd>protect_braced_quotes</kbd> class property to <samp>TRUE</samp>.</p>
- <p><strong>试翻译:</strong> 当排版类与模板解析器类结合使用时,为了使显示正常,经常需要把单引号和双引号放在大括号中。如果你是这种情况,可以把<kbd>protect_braced_quotes</kbd>类属性设置为 <samp>TRUE</samp>.</p>
- <p>Usage example:</p>
- <p><strong>试翻译:</strong>例子:</p>
- <code>$this->load->library('typography');<br />
- $this->typography->protect_braced_quotes = TRUE;
- </code><p> </p>
- <div id="Contributors">
- 翻译贡献者:
- drazzi, Hex, icebird, neversaylate, noproblem, tonera, zhou78620051</div>
- <div id="DocDate">
- 最后修改: 2012-11-14 14:56:28</div>
- </div>
- <!-- END CONTENT -->
- <div id="footer">
- <p>
- 上一个主题: <a href="parser.html">模板解析器</a> · <a href="#top">页首</a>
- · <a href="../index.html">用户指南首页</a> · 下一个主题: <a href="unit_testing.html">单元测试类</a> </p>
- <p><a href="#">CodeIgniter</a> · 版权所有 © 2006-2013 · <a href="#">Ellislab, Inc.</a></p>
- <p>中文化: <a href="#">CodeIgniter 中国</a> · 制作: Hex · 版本: 1.30 · 鸣谢: 子非鱼</p>
- </div>
- </body>
- </html>
|