diff --git a/lib/bitter/formats/symphony.php b/lib/bitter/formats/symphony.php index 6f74a2d..c09c778 100755 --- a/lib/bitter/formats/symphony.php +++ b/lib/bitter/formats/symphony.php @@ -1,23 +1,23 @@ output = $source; - + $this->processTabs(); $this->processLines(); - + return sprintf( '
%s', $this->output ); } - + protected function processTabs() { // first split the output into manageable chunks $lines = explode(PHP_EOL, $this->output); @@ -25,7 +25,7 @@ protected function processTabs() { // fix lines one by one for ($x = 0; $x < $linesCount; $x++) { // while there are still tabs - while (strpos($lines[$x], "\t") !== FALSE) { + while (strpos($lines[$x], "\t") !== false) { // replace tabs for spaces $lines[$x] = preg_replace_callback('%^([^\t]*)([\t]+)%', array($this, 'processTabsLine'), $lines[$x]); } @@ -33,72 +33,72 @@ protected function processTabs() { // concat the final output $this->output = implode(PHP_EOL, $lines); } - + protected function processTabsLine($matches) { return $matches[1] . str_repeat( ' ', strlen($matches[2]) * $this->tabsize ); } - + protected function processLines() { $tokens = preg_split('%(|)%', $this->output, 0, PREG_SPLIT_DELIM_CAPTURE); $stack = array(); $this->output = ''; - + $this->startLine(); - + foreach ($tokens as $token) { // Close: if (preg_match('%^%', $token)) { array_pop($stack); $this->output .= $token; } - + // Open: else if (preg_match('%^<%', $token)) { array_push($stack, $token); $this->output .= $token; } - + else { $characters = preg_split('//', $token); - + foreach ($characters as $character) { if ($character == "\n") { $this->endLine(); - + foreach ($stack as $alt_token) $this->output .= ''; } - + $this->output .= $character; - + if ($character == "\n") { $this->startLine(); - + foreach ($stack as $alt_token) $this->output .= $alt_token; } } } } - + $this->endLine(); } - + protected function startLine() { $this->output .= "