6 * @copyright 2012-2020 Leaf Corcoran
8 * @license http://opensource.org/licenses/MIT MIT
10 * @link http://scssphp.github.io/scssphp
13 namespace ScssPhp\ScssPhp\Formatter
;
15 use ScssPhp\ScssPhp\Formatter
;
16 use ScssPhp\ScssPhp\Formatter\OutputBlock
;
21 * @author Leaf Corcoran <leafot@gmail.com>
23 class Expanded
extends Formatter
28 public function __construct()
30 $this->indentLevel
= 0;
31 $this->indentChar
= ' ';
35 $this->tagSeparator
= ', ';
36 $this->assignSeparator
= ': ';
37 $this->keepSemicolons
= true;
43 protected function indentStr()
45 return str_repeat($this->indentChar
, $this->indentLevel
);
51 protected function blockLines(OutputBlock
$block)
53 $inner = $this->indentStr();
55 $glue = $this->break . $inner;
57 foreach ($block->lines
as $index => $line) {
58 if (substr($line, 0, 2) === '/*') {
59 $block->lines
[$index] = preg_replace('/\r\n?|\n|\f/', $this->break, $line);
63 $this->write($inner . implode($glue, $block->lines
));
65 if (empty($block->selectors
) ||
! empty($block->children
)) {
66 $this->write($this->break);