From 36554284ad394507abbabce63d0af4b1318af48e Mon Sep 17 00:00:00 2001 From: Rowan Lewis Date: Sat, 5 Mar 2011 15:34:40 +1000 Subject: [PATCH 1/2] Fixed issue where closing spans where inserted after their parent elements closing tag. --- lib/bitter/formats/symphony.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bitter/formats/symphony.php b/lib/bitter/formats/symphony.php index ff79cd3..48b3924 100755 --- a/lib/bitter/formats/symphony.php +++ b/lib/bitter/formats/symphony.php @@ -56,9 +56,9 @@ protected function processLines() { foreach ($characters as $character) { if ($character == "\n") { - $this->endLine(); - foreach ($stack as $alt_token) $this->output .= ''; + + $this->endLine(); } $this->output .= $character; From cc3d0d15c240e0880ef5de4554796802334286ec Mon Sep 17 00:00:00 2001 From: Rowan Lewis Date: Wed, 9 Mar 2011 11:00:22 +1000 Subject: [PATCH 2/2] Fixed regular expression used for replacing tabs. --- lib/bitter/formats/symphony.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/bitter/formats/symphony.php b/lib/bitter/formats/symphony.php index 48b3924..df742f1 100755 --- a/lib/bitter/formats/symphony.php +++ b/lib/bitter/formats/symphony.php @@ -2,7 +2,7 @@ /*----------------------------------------------------------------------------*/ class BitterFormatSymphony extends BitterFormat { - protected $tabsize = 4; + protected $tabsize = 2; protected $line = 1; protected $output = ''; @@ -19,19 +19,17 @@ public function process($source) { } protected function processTabs() { - if (!function_exists('__expander')) eval(" - function __expander(\$matches) { - return \$matches[1] . str_repeat( - ' ', strlen(\$matches[2]) * {$this->tabsize} - (strlen(\$matches[1]) % {$this->tabsize}) - ); - } - "); - while (strstr($this->output, "\t")) { - $this->output = preg_replace_callback('%^([^\t\n]*)(\t+)%m', '__expander', $this->output); + $this->output = preg_replace_callback('%^([^\t]*)(\t+)%m', array($this, 'processTabsLine'), $this->output); } } + protected function processTabsLine($matches) { + return $matches[1] . str_repeat( + ' ', strlen($matches[2]) * $this->tabsize - (strlen($matches[1]) % $this->tabsize) + ); + } + protected function processLines() { $tokens = preg_split('%(|)%', $this->output, 0, PREG_SPLIT_DELIM_CAPTURE); $stack = array(); $this->output = '';