← All changes
|
assets/libraries/scssphp/src/Formatter/Compressed.php
+27
-5
7.13.2
→
6.28
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * SCSSPHP |
| 4 | 4 | * |
| 5 | - * @copyright 2012-2018 Leaf Corcoran | |
| 5 | + * @copyright 2012-2015 Leaf Corcoran | |
| 6 | 6 | * |
| 7 | 7 | * @license http://opensource.org/licenses/MIT MIT |
| 8 | 8 | * |
| 9 | 9 | * @link http://leafo.github.io/scssphp |
| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | use Leafo\ScssPhp\Formatter; |
| 15 | 15 | use Leafo\ScssPhp\Formatter\OutputBlock; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Compressed formatter | |
| 18 | + * SCSS compressed formatter | |
| 19 | 19 | * |
| 20 | 20 | * @author Leaf Corcoran <[email protected]> |
| 21 | 21 | */ |
| 22 | 22 | class Compressed extends Formatter |
| @@ -32,14 +32,25 @@ | ||
| 32 | 32 | $this->open = '{'; |
| 33 | 33 | $this->close = '}'; |
| 34 | 34 | $this->tagSeparator = ','; |
| 35 | 35 | $this->assignSeparator = ':'; |
| 36 | - $this->keepSemicolons = false; | |
| 37 | 36 | } |
| 38 | 37 | |
| 39 | 38 | /** |
| 40 | 39 | * {@inheritdoc} |
| 41 | 40 | */ |
| 41 | + public function stripSemicolon(&$lines) | |
| 42 | + { | |
| 43 | + if (($count = count($lines)) | |
| 44 | + && substr($lines[$count - 1], -1) === ';' | |
| 45 | + ) { | |
| 46 | + $lines[$count - 1] = substr($lines[$count - 1], 0, -1); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * {@inheritdoc} | |
| 52 | + */ | |
| 42 | 53 | public function blockLines(OutputBlock $block) |
| 43 | 54 | { |
| 44 | 55 | $inner = $this->indentStr(); |
| 45 | 56 | |
| @@ -52,11 +63,22 @@ | ||
| 52 | 63 | $block->lines[$index] = '/*' . substr($line, 3); |
| 53 | 64 | } |
| 54 | 65 | } |
| 55 | 66 | |
| 56 | - $this->write($inner . implode($glue, $block->lines)); | |
| 67 | + echo $inner . implode($glue, $block->lines); | |
| 57 | 68 | |
| 58 | 69 | if (! empty($block->children)) { |
| 59 | - $this->write($this->break); | |
| 70 | + echo $this->break; | |
| 60 | 71 | } |
| 72 | + } | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * {@inherit} | |
| 76 | + */ | |
| 77 | + public function format(OutputBlock $block) | |
| 78 | + { | |
| 79 | + return parent::format($block); | |
| 80 | + | |
| 81 | + // TODO: we need to fix the 2 "compressed" tests where the "close" is applied | |
| 82 | + return trim(str_replace(';}', '}', parent::format($block))); | |
| 61 | 83 | } |
| 62 | 84 | } |