/** * Parses out specific white space before or after cetain tags, rematches * tags where necessary, and processes line breaks. * * @param string Text to process * @param bool Whether to translate newlines to HTML breaks (unused) * * @return string Processed text */ function parse_whitespace_newlines($text, $do_nl2br = true) { $text = parent::parse_whitespace_newlines($text, $do_nl2br); if ($this->is_wysiwyg('ie')) { // heading tags that span multiple lines shouldn't have p tags within // and they can't be split into multiple tags $text = preg_replace_callback(array('#\\[((h)=.*)\\](.*)\\[/\\2\\]#siU', '#\\[((page))\\](.*)\\[/\\2\\]#siU'), array($this, 'rematchIELinebreaks'), $text); // close any open p tags that come up to heading tags $text = preg_replace(array('#(\\[h=[1-6]\\].*\\[/h\\])#siU', '#(\\[page\\].*\\[/page\\])#siU'), '</p>\\1<p>', $text); $text = str_replace('<p></p>', '', $text); } return $text; }