1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Quick fix for trailing line-breaks on block-level elements.

This commit is contained in:
Cameron
2013-06-14 16:26:56 -07:00
parent 2e1fd600da
commit c6cec3cf61

View File

@@ -1461,7 +1461,7 @@ class e_parse extends e_parser
$opts['nobreak'] = true; $opts['nobreak'] = true;
break; break;
case 'table' : // strip <br /> from end of <table> case 'table' : // strip <br /> from inside of <table>
$convertNL = FALSE; $convertNL = FALSE;
// break; // break;
@@ -1735,7 +1735,10 @@ class e_parse extends e_parser
} }
} }
if ($convertNL)
if($convertNL == true)
{ {
// Default replaces all \n with <br /> for HTML display // Default replaces all \n with <br /> for HTML display
$nl_replace = '<br />'; $nl_replace = '<br />';
@@ -1747,10 +1750,10 @@ class e_parse extends e_parser
{ {
$nl_replace = "\n"; $nl_replace = "\n";
} }
$sub_blk = str_replace(E_NL, $nl_replace, $sub_blk); $sub_blk = str_replace(E_NL, $nl_replace, $sub_blk);
} }
$ret_parser .= $sub_blk; $ret_parser .= $sub_blk;
} // End of 'normal' processing for a block of text } // End of 'normal' processing for a block of text
@@ -1763,6 +1766,19 @@ class e_parse extends e_parser
$ret_parser .= $full_text; $ret_parser .= $full_text;
} }
} }
// Quick Fix - Remove trailing <br /> on block-level elements (eg. div, pre, table, etc. )
$srch = array();
$repl = array();
foreach($this->blockTags as $val)
{
$srch[] = "</".$val."><br />";
$repl[] = "</".$val.">";
}
$ret_parser = str_replace($srch, $repl, $ret_parser);
return trim($ret_parser); return trim($ret_parser);
} }
@@ -2482,6 +2498,8 @@ class e_parser
); );
private $scriptTags = array('script','applet','iframe'); //allowed whem $pref['post_script'] is enabled. private $scriptTags = array('script','applet','iframe'); //allowed whem $pref['post_script'] is enabled.
protected $blockTags = array('pre','div','h1','h2','h3','h4','h5','h6','blockquote'); // element includes its own line-break.
public function __construct() public function __construct()
{ {
$this->init(); $this->init();