5 * @copyright 2012-2018 Leaf Corcoran
7 * @license http://opensource.org/licenses/MIT MIT
9 * @link http://leafo.github.io/scssphp
12 namespace Leafo\ScssPhp\Formatter
;
14 use Leafo\ScssPhp\Formatter
;
15 use Leafo\ScssPhp\Formatter\OutputBlock
;
20 * @author Leaf Corcoran <leafot@gmail.com>
22 class Expanded
extends Formatter
27 public function __construct()
29 $this->indentLevel
= 0;
30 $this->indentChar
= ' ';
34 $this->tagSeparator
= ', ';
35 $this->assignSeparator
= ': ';
36 $this->keepSemicolons
= true;
42 protected function indentStr()
44 return str_repeat($this->indentChar
, $this->indentLevel
);
50 protected function blockLines(OutputBlock
$block)
52 $inner = $this->indentStr();
54 $glue = $this->break . $inner;
56 foreach ($block->lines
as $index => $line) {
57 if (substr($line, 0, 2) === '/*') {
58 $block->lines
[$index] = preg_replace('/(\r|\n)+/', $glue, $line);
62 $this->write($inner . implode($glue, $block->lines
));
64 if (empty($block->selectors
) ||
! empty($block->children
)) {
65 $this->write($this->break);