\CodeIgniter\TypographyTypography

Typography Class

Summary

Methods
Properties
Constants
autoTypography()
formatCharacters()
nl2brExceptPre()
$blockElements
$skipElements
$inlineElements
$innerBlockRequired
$lastBlockElement
$protectBracedQuotes
No constants found
formatNewLines()
protectCharacters()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$blockElements

$blockElements : string

Block level elements that should not be wrapped inside <p> tags

Type

string

$skipElements

$skipElements : string

Elements that should not have <p> and <br /> tags within them.

Type

string

$inlineElements

$inlineElements : string

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

Type

string

$innerBlockRequired

$innerBlockRequired : array

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

Type

array

$lastBlockElement

$lastBlockElement : string

the last block element parsed

Type

string

$protectBracedQuotes

$protectBracedQuotes : boolean

whether or not to protect quotes within { curly braces }

Type

boolean

Methods

autoTypography()

autoTypography(string  $str, boolean  $reduce_linebreaks = false) : string

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

Parameters

string $str
boolean $reduce_linebreaks

whether to reduce more then two consecutive newlines to two

Returns

string

formatCharacters()

formatCharacters(string  $str) : string

Format Characters

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

Parameters

string $str

Returns

string

nl2brExceptPre()

nl2brExceptPre(string  $str) : string

Convert newlines to HTML line breaks except within PRE tags

Parameters

string $str

Returns

string

formatNewLines()

formatNewLines(string  $str) : string

Format Newlines

Converts newline characters into either

tags or

Parameters

string $str

Returns

string

protectCharacters()

protectCharacters(array  $match) : string

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

Parameters

array $match

Returns

string