Skip to content

Commit

Permalink
Remove trailing whitespace on empty lines created with NewLines filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Garbe committed Sep 10, 2012
1 parent 52cdebf commit 78cb963
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Beautifier/Filter/NewLines.filter.php
Expand Up @@ -110,5 +110,28 @@ public function __call($sMethod, $aArgs)
}
return PHP_Beautifier_Filter::BYPASS;
}

/**
* Called from {@link PHP_Beautifier::process()} at the end of processing
* The post-process must be made in {@link PHP_Beautifier::$aOut}
*
* @access public
* @return void
*/
public function postProcess()
{
foreach ($this->oBeaut->aOut as $i => &$out)
{
if (is_string($out) && $out != '' && trim($out) == '')
{
$trimed = trim($out, $this->oBeaut->getIndentChar());
if ($trimed != $out && strpos($this->oBeaut->aOut[$i-1],"\n") !== false
&& strpos($this->oBeaut->aOut[$i+1],"\n") !== false )
{
$out = $trimed;
}
}
}
}
}
?>

0 comments on commit 78cb963

Please sign in to comment.