From d54078fff55f74ee4fd320b27f8129b48bdcd3fa Mon Sep 17 00:00:00 2001
From: admin , etc.) do not get
+ * wrapped in paragraph tags we will add a closing
tag right after the block element + * ends. Later on we'll do some further clean up. + * + */ + $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "
\\1\\2\\3", $str); + $str = preg_replace("#(block_elements.")(.*?>)#", "\\1\\2\\3", $str); + /* * Convert "ignore" tags to tempoarary marker * @@ -149,10 +162,10 @@ class Auto_typography { * it encounters. Certain inline tags, like image * tags, links, span tags, etc. will be adversely * affected if they are split out so we'll convert - * the opening < temporarily to: {{{tag}}} + * the opening < temporarily to: {@TAG} * - */ - $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{{{tag}}}\\1\\2", $str); + */ + $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str); /* * Split the string at every tag @@ -188,7 +201,7 @@ class Auto_typography { * Well also set the "process" flag which allows us * to skip
tags and a few other things. * - */ + */ if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match)) { if (preg_match("#".$this->skip_elements."#", $match['2'])) @@ -210,20 +223,51 @@ class Auto_typography { $str .= $this->format_newlines($chunk); } + + /* + * Clean up paragraph tags before/after "block" elements + * + * Earlier we added tags before/after block level elements. + * Then, we added paragraph tags around double line breaks. This + * potentially created incorrectly formatted paragraphs so we'll + * clean it up here. + * + */ + $str = preg_replace("#({@TAG}.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3", $str); + $str = preg_replace("#({@TAG}/.*?)(".$this->block_elements.")(.*?>)
#", "\\1\\2\\3", $str); + // Convert Quotes and other characters $str = $this->format_characters($str); - - // We'll swap our temporary markers back and do some clean up. + + // Final clean up $str = preg_replace('#(\n*
)#', '', $str); $str = preg_replace('#() #', "\\1", $str); - + $str = str_replace( - array('
', '', '{{{tag}}}', '{{{DQ}}}', '{{{SQ}}}'), - array('
', '', '<', '"', "'"), + array( + '
', + '', + '
', + '
', + '{@TAG}', + '{@DQ}', + '{@SQ}', + '' + ), + array( + '', + '', + '
', + '
', + '<', + '"', + "'", + '' + ), $str - ); + ); - return trim($str); + return $str; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b