simple balancing on throwaway divs

This commit is contained in:
Klaus Leithoff 2012-07-31 10:59:56 +00:00
parent b0267b6744
commit af782d1fc7

View File

@ -197,7 +197,15 @@ function hl_my_tag_transform($element, $attribute_array=0)
function hl_email_tag_transform($element, $attribute_array=0)
{
static $lastelement;
if ($element=='div' && $element==$lastelement && ($attribute_array==0 || empty($attribute_array))) return '';
static $throwawaycounter;
if (is_null($throwawaycounter)) $throwawaycounter = 0;
//if ($throwawaycounter>250) error_log(__METHOD__.__LINE__.' '.$throwawaycounter);
if ($element=='div' && $element==$lastelement && ($attribute_array==0 || empty($attribute_array)))
{
if (is_array($attribute_array)) $throwawaycounter++;
if ($attribute_array==0 && $throwawaycounter>0) $throwawaycounter--;
if ($throwawaycounter>0) return '';
}
if (is_array($attribute_array) && !empty($attribute_array) && $element=='div')
{
$lastelement = 'div_with_attr';