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
;
18 * Compressed formatter
20 * @author Leaf Corcoran <leafot@gmail.com>
22 class Compressed
extends Formatter
27 public function __construct()
29 $this->indentLevel
= 0;
30 $this->indentChar
= ' ';
34 $this->tagSeparator
= ',';
35 $this->assignSeparator
= ':';
36 $this->keepSemicolons
= false;
42 public function blockLines(OutputBlock
$block)
44 $inner = $this->indentStr();
46 $glue = $this->break . $inner;
48 foreach ($block->lines
as $index => $line) {
49 if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') {
50 unset($block->lines
[$index]);
51 } elseif (substr($line, 0, 3) === '/*!') {
52 $block->lines
[$index] = '/*' . substr($line, 3);
56 $this->write($inner . implode($glue, $block->lines
));
58 if (! empty($block->children
)) {
59 $this->write($this->break);
64 * Output block selectors
66 * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
68 protected function blockSelectors(OutputBlock
$block)
70 $inner = $this->indentStr();
76 str_replace([' > ', ' + ', ' ~ '], ['>', '+', '~'], $block->selectors
)
78 . $this->open
. $this->break