protected function protectCharacters(array
$match): string
{ return str_replace(["'", '"', '--', ' '
],
['{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'
],
$match[0
]);
} /**
* Convert newlines to HTML line breaks except within PRE tags
*/
public function nl2brExceptPre(string
$str): string
{ $newstr = '';
$docTypes =
new DocTypes();
for ($ex =
explode('pre>',
$str),
$ct =
count($ex),
$i = 0;
$i <
$ct;
$i++
) { $xhtml = !
($docTypes->html5 ?? false
);
$newstr .= (($i % 2
) === 0
) ?
nl2br($ex[$i],
$xhtml) :
$ex[$i];
if ($ct - 1 !==
$i) { $newstr .= 'pre>';
} } return $newstr;
}