From 78cb9636d41a55cf2f2a017fd6fdbdc0287ce11d Mon Sep 17 00:00:00 2001 From: Olivier Garbe Date: Mon, 10 Sep 2012 03:04:11 +0200 Subject: [PATCH] Remove trailing whitespace on empty lines created with NewLines filter --- Beautifier/Filter/NewLines.filter.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Beautifier/Filter/NewLines.filter.php b/Beautifier/Filter/NewLines.filter.php index 436c82e..214d306 100755 --- a/Beautifier/Filter/NewLines.filter.php +++ b/Beautifier/Filter/NewLines.filter.php @@ -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; + } + } + } + } } ?>