Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
/**
4
 * SCSSPHP
5
 *
6
 * @copyright 2012-2020 Leaf Corcoran
7
 *
8
 * @license http://opensource.org/licenses/MIT MIT
9
 *
10
 * @link http://scssphp.github.io/scssphp
11
 */
12
 
13
namespace ScssPhp\ScssPhp\Formatter;
14
 
15
use ScssPhp\ScssPhp\Formatter;
16
 
17
/**
18
 * Crunched formatter
19
 *
20
 * @author Anthon Pang <anthon.pang@gmail.com>
21
 *
22
 * @deprecated since 1.4.0. Use the Compressed formatter instead.
23
 *
24
 * @internal
25
 */
26
class Crunched extends Formatter
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function __construct()
32
    {
33
        @trigger_error('The Crunched formatter is deprecated since 1.4.0. Use the Compressed formatter instead.', E_USER_DEPRECATED);
34
 
35
        $this->indentLevel = 0;
36
        $this->indentChar = '  ';
37
        $this->break = '';
38
        $this->open = '{';
39
        $this->close = '}';
40
        $this->tagSeparator = ',';
41
        $this->assignSeparator = ':';
42
        $this->keepSemicolons = false;
43
    }
44
 
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function blockLines(OutputBlock $block)
49
    {
50
        $inner = $this->indentStr();
51
 
52
        $glue = $this->break . $inner;
53
 
54
        foreach ($block->lines as $index => $line) {
55
            if (substr($line, 0, 2) === '/*') {
56
                unset($block->lines[$index]);
57
            }
58
        }
59
 
60
        $this->write($inner . implode($glue, $block->lines));
61
 
62
        if (! empty($block->children)) {
63
            $this->write($this->break);
64
        }
65
    }
66
 
67
    /**
68
     * Output block selectors
69
     *
70
     * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
71
     */
72
    protected function blockSelectors(OutputBlock $block)
73
    {
74
        assert(! empty($block->selectors));
75
 
76
        $inner = $this->indentStr();
77
 
78
        $this->write(
79
            $inner
80
            . implode(
81
                $this->tagSeparator,
82
                str_replace([' > ', ' + ', ' ~ '], ['>', '+', '~'], $block->selectors)
83
            )
84
            . $this->open . $this->break
85
        );
86
    }
87
}