Skip to content

CI_Typography

Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

CI_Typography

Typography Class

  • Class name: CI_Typography
  • Namespace:

Properties

$block_elements

public string $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'

Block level elements that should not be wrapped inside

tags

  • Visibility: public

$skip_elements

public string $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'

Elements that should not have

and
tags within them.

  • Visibility: public

$inline_elements

public string $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'

Tags we want the parser to completely ignore when splitting the string.

  • Visibility: public

$inner_block_required

public array $inner_block_required = array('blockquote')

array of block level elements that require inner content to be within another block level element

  • Visibility: public

$last_block_element

public string $last_block_element = ''

the last block element parsed

  • Visibility: public

$protect_braced_quotes

public boolean $protect_braced_quotes = FALSE

whether or not to protect quotes within { curly braces }

  • Visibility: public

Methods

auto_typography

string CI_Typography::auto_typography($str, $reduce_linebreaks)

Auto Typography

This function converts text, making it typographically correct:

  • Converts double spaces into paragraphs.
  • Converts single line breaks into
    tags
  • Converts single and double quotes into correctly facing curly quote entities.
  • Converts three dots into ellipsis.
  • Converts double dashes into em-dashes.
  • Converts two spaces into entities
  • Visibility: public

Arguments

  • $str mixed
  • $reduce_linebreaks mixed

format_characters

string CI_Typography::format_characters($str)

Format Characters

This function mainly converts double and single quotes to curly entities, but it also converts em-dashes, double spaces, and ampersands

  • Visibility: public

Arguments

  • $str mixed

_format_newlines

string CI_Typography::_format_newlines($str)

Format Newlines

Converts newline characters into either

tags or

  • Visibility: protected

Arguments

  • $str mixed

_protect_characters

string CI_Typography::_protect_characters($match)

Protect Characters

Protects special characters from being formatted later We don't want quotes converted within tags so we'll temporarily convert them to {@DQ} and {@SQ} and we don't want double dashes converted to emdash entities, so they are marked with {@DD} likewise double spaces are converted to {@NBS} to prevent entity conversion

  • Visibility: protected

Arguments

  • $match mixed

nl2br_except_pre

string CI_Typography::nl2br_except_pre($str)

Convert newlines to HTML line breaks except within PRE tags

  • Visibility: public

Arguments

  • $str mixed
Clone this wiki locally