tags public $blockElements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; // Elements that should not have
and
tags within them.
public $skipElements = 'p|pre|ol|ul|dl|object|table|h\d';
// Tags we want the parser to completely ignore when splitting the string.
public $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';
// array of block level elements that require inner content to be within another block level element
public $innerBlockRequired = ['blockquote'];
// the last block element parsed
public $lastBlockElement = '';
// whether or not to protect quotes within { curly braces }
public $protectBracedQuotes = false;
public $matching = [
'deu' => 'low', // except for Switzerland
'eng' => 'default',
'fra' => 'angle',
];
/**
* Automatically uses the typography specified.
* By default, uses Configure::read('App.language') to determine locale preference.
* It will then try to match the language to the type of characters used.
* You can hardwire this by using Configure::read('Typography.locale'); and directly set it
* to 'low' or 'angle'. It will then disregard the language.
*
* 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
*
* @param string $str Text
* @param bool $reduceLinebreaks Whether to reduce more then two consecutive newlines to two
* @return string Text
*/
public function autoTypography($str, $reduceLinebreaks = false) {
if ($str === '') {
return '';
}
// Standardize Newlines to make matching easier
if (strpos($str, "\r") !== false) {
$str = str_replace(["\r\n", "\r"], "\n", $str);
}
// Reduce line breaks. If there are more than two consecutive linebreaks
// we'll compress them down to a maximum of two since there's no benefit to more.
if ($reduceLinebreaks === true) {
$str = preg_replace("/\n\n+/", "\n\n", $str);
}
// HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
$htmlComments = [];
if (strpos($str, '