排版类¶
排版类提供了一些方法用于帮助你格式化文本。
类参考¶
- class CI_Typography¶
- $protect_braced_quotes = FALSE
- 当排版类和 模板解析器类 同时使用时,经常需要保护大括号中的的单引号和双引号不被转换。 要保护这个,将 protect_braced_quotes 属性设置为 TRUE 。 - 使用示例: - $this->load->library('typography'); $this->typography->protect_braced_quotes = TRUE; 
 - format_characters($str)¶
- Parameters: - $str (string) – Input string
 - Returns: - Formatted string - Return type: - string - 该方法和上面的 auto_typography() 类似,但是它只对字符进行处理: - 除了出现在标签中的引号外,引号会被转换成正确的实体。
- 撇号被转换为相应的实体。
- 双破折号(像 – 或–)被转换成 em — 破折号。
- 三个连续的点也会被转换为省略号… 。
- 句子后连续的多个空格将被转换为   以便在网页中显示。
 - 使用示例: - $string = $this->typography->format_characters($string); 
 - nl2br_except_pre($str)¶
- Parameters: - $str (string) – Input string
 - Returns: - Formatted string - Return type: - string - 将换行符转换为 <br /> 标签,忽略 <pre> 标签中的换行符。除了对 <pre> 标签中的换行处理有所不同之外,这个函数和 PHP 函数 nl2br() 是完全一样的。 - 使用示例: - $string = $this->typography->nl2br_except_pre($string);