CodeIgniter v4.5 API

Typography
in package

Typography Class

Tags
see
TypographyTest

Table of Contents

Properties

$blockElements  : string
Block level elements that should not be wrapped inside <p> tags
$inlineElements  : string
Tags we want the parser to completely ignore when splitting the string.
$innerBlockRequired  : array<string|int, mixed>
array of block level elements that require inner content to be within another block level element
$lastBlockElement  : string
the last block element parsed
$protectBracedQuotes  : bool
whether or not to protect quotes within { curly braces }
$skipElements  : string
Elements that should not have <p> and <br> tags within them.

Methods

autoTypography()  : string
Auto Typography
formatCharacters()  : string
Format Characters
nl2brExceptPre()  : string
Convert newlines to HTML line breaks except within PRE tags
formatNewLines()  : string
Format Newlines
protectCharacters()  : string
Protect Characters

Properties

$blockElements

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

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

$inlineElements

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

public string $inlineElements = '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'

$innerBlockRequired

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

public array<string|int, mixed> $innerBlockRequired = ['blockquote']

$lastBlockElement

the last block element parsed

public string $lastBlockElement = ''

$protectBracedQuotes

whether or not to protect quotes within { curly braces }

public bool $protectBracedQuotes = false

$skipElements

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

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

Methods

autoTypography()

Auto Typography

public autoTypography(string $str[, bool $reduceLinebreaks = false ]) : string

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
$str : string
$reduceLinebreaks : bool = false

whether to reduce more then two consecutive newlines to two

Return values
string

formatCharacters()

Format Characters

public formatCharacters(string $str) : string

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

Parameters
$str : string
Return values
string

nl2brExceptPre()

Convert newlines to HTML line breaks except within PRE tags

public nl2brExceptPre(string $str) : string
Parameters
$str : string
Return values
string

formatNewLines()

Format Newlines

protected formatNewLines(string $str) : string

Converts newline characters into either

tags or

Parameters
$str : string
Return values
string

protectCharacters()

Protect Characters

protected protectCharacters(array<string|int, mixed> $match) : string

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

Parameters
$match : array<string|int, mixed>
Return values
string

        
On this page

Search results