Skip to content

Commit

Permalink
Merge branch 'integration'
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Abbott committed May 20, 2011
2 parents f94f3ba + cc3d0d1 commit 64dac30
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/bitter/formats/symphony.php
Expand Up @@ -2,7 +2,7 @@
/*----------------------------------------------------------------------------*/

class BitterFormatSymphony extends BitterFormat {
protected $tabsize = 4;
protected $tabsize = 2;
protected $line = 1;
protected $output = '';

Expand All @@ -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('%(<span class=".*?">|</span>)%', $this->output, 0, PREG_SPLIT_DELIM_CAPTURE);
$stack = array(); $this->output = '';
Expand All @@ -56,9 +54,9 @@ protected function processLines() {

foreach ($characters as $character) {
if ($character == "\n") {
$this->endLine();

foreach ($stack as $alt_token) $this->output .= '</span>';

$this->endLine();
}

$this->output .= $character;
Expand Down

0 comments on commit 64dac30

Please sign in to comment.