Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/scssphp/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions lib/scssphp/.travis.yml

This file was deleted.

642 changes: 1 addition & 641 deletions lib/scssphp/LICENSE.md

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions lib/scssphp/Makefile

This file was deleted.

33 changes: 23 additions & 10 deletions lib/scssphp/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
# scssphp v0.1.1
### <http://leafo.net/scssphp>
# scssphp
### <http://leafo.github.io/scssphp>

[![Build Status](https://secure.travis-ci.org/leafo/scssphp.png)](http://travis-ci.org/leafo/scssphp)
[![Build](https://travis-ci.org/leafo/scssphp.svg?branch=master)](http://travis-ci.org/leafo/scssphp)
[![License](https://poser.pugx.org/leafo/scssphp/license.svg)](https://packagist.org/packages/leafo/scssphp)

`scssphp` is a compiler for SCSS written in PHP.

It implements SCSS 3.2.12. It does not implement the SASS syntax, only the SCSS
syntax.

Checkout the homepage, <http://leafo.net/scssphp>, for directions on how to use.
Checkout the homepage, <http://leafo.github.io/scssphp>, for directions on how to use.

## Running Tests

`scssphp` uses [PHPUnit](https://github.com/sebastianbergmann/phpunit) for testing.

Run the following command from the root directory to run every test:

phpunit tests
vendor/bin/phpunit tests

There are two kinds of tests in the `tests/` directory:
There are several tests in the `tests/` directory:

* `ApiTest.php` contains various unit tests that test the PHP interface.
* `ExceptionTest.php` contains unit tests that test for exceptions thrown by the parser and compiler.
* `FailingTest.php` contains tests reported in Github issues that demonstrate compatibility bugs.
* `InputTest.php` compiles every `.scss` file in the `tests/inputs` directory
then compares to the respective `.css` file in the `tests/outputs` directory.
* `ScssTest.php` extracts (ruby) `scss` tests from the `tests/scss_test.rb` file.
* `ServerTest.php` contains functional tests for the `Server` class.

When changing any of the tests in `tests/inputs`, the tests will most likely
fail because the output has changed. Once you verify that the output is correct
you can run the following command to rebuild all the tests:

BUILD=true phpunit tests
BUILD=1 vendor/bin/phpunit tests

This will compile all the tests, and save results into `tests/outputs`.

To enable the `scss` compatibility tests:

TEST_SCSS_COMPAT=1 vendor/bin/phpunit tests

## Coding Standard

`scssphp` source conforms to [PSR2](http://www.php-fig.org/psr/psr-2/).

Run the following command from the root directory to check the code for "sniffs".

vendor/bin/phpcs --standard=PSR2 bin src tests
200 changes: 169 additions & 31 deletions lib/scssphp/bin/pscss
Original file line number Diff line number Diff line change
@@ -1,66 +1,204 @@
#!/usr/bin/env php
<?php
/**
* SCSSPHP
*
* @copyright 2012-2015 Leaf Corcoran
*
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.github.io/scssphp
*/

error_reporting(E_ALL);

include 'scss.inc.php';
if (version_compare(PHP_VERSION, '5.4') < 0) {
die('Requires PHP 5.4 or above');
}

include __DIR__ . '/../scss.inc.php';

use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Parser;
use Leafo\ScssPhp\Version;

$style = null;
$loadPaths = null;
$precision = null;
$dumpTree = false;
$inputFile = null;
$changeDir = false;
$debugInfo = false;
$lineNumbers = false;
$ignoreErrors = false;
$encoding = false;

/**
* Parse argument
*
* @param integer $i
* @param array $options
*
* @return string|null
*/
function parseArgument(&$i, $options) {
global $argc;
global $argv;

if (! preg_match('/^(?:' . implode('|', (array) $options) . ')=?(.*)/', $argv[$i], $matches)) {
return;
}

$opts = getopt('hvTf:', array('help', 'version'));
if (strlen($matches[1])) {
return $matches[1];
}

function has() {
global $opts;
if ($i + 1 < $argc) {
$i++;

foreach (func_get_args() as $arg) {
if (isset($opts[$arg])) {
return true;
}
return $argv[$i];
}

return false;
}

if (has("h", "help")) {
$exe = array_shift($argv);
for ($i = 1; $i < $argc; $i++) {
if ($argv[$i] === '-h' || $argv[$i] === '--help') {
$exe = $argv[0];

$HELP = <<<EOT
Usage: $exe [options] < input-file
$HELP = <<<EOT
Usage: $exe [options] [input-file]

Options include:

-h, --help Show this message
-v, --version Print the version
-f=format Set the output format (compressed, crunched, expanded, or nested)
-T Dump formatted parse tree
-h, --help Show this message
--continue-on-error Continue compilation (as best as possible) when error encountered
--debug-info Annotate selectors with CSS referring to the source file and line number
-f=format Set the output format (compact, compressed, crunched, expanded, or nested)
-i=path Set import path
--iso8859-1 Use iso8859-1 encoding instead of utf-8 (default utf-8)
--line-numbers Annotate selectors with comments referring to the source file and line number
-p=precision Set decimal number precision (default 5)
-T Dump formatted parse tree
-v, --version Print the version

EOT;
exit($HELP);
}
exit($HELP);
}

if ($argv[$i] === '-v' || $argv[$i] === '--version') {
exit(Version::VERSION . "\n");
}

if ($argv[$i] === '--continue-on-error') {
$ignoreErrors = true;
continue;
}

if ($argv[$i] === '--debug-info') {
$debugInfo = true;
continue;
}

if ($argv[$i] === '--iso8859-1') {
$encoding = 'iso8859-1';
continue;
}

if ($argv[$i] === '--line-numbers' || $argv[$i] === '--line-comments') {
$lineNumbers = true;
continue;
}

if ($argv[$i] === '-T') {
$dumpTree = true;
continue;
}

$value = parseArgument($i, array('-f', '--style'));

if (isset($value)) {
$style = $value;
continue;
}

$value = parseArgument($i, array('-i', '--load_paths'));

if (isset($value)) {
$loadPaths = $value;
continue;
}

$value = parseArgument($i, array('-p', '--precision'));

if (isset($value)) {
$precision = $value;
continue;
}

if (has("v", "version")) {
exit(Compiler::$VERSION . "\n");
if (file_exists($argv[$i])) {
$inputFile = $argv[$i];
continue;
}
}

$data = "";

while (!feof(STDIN)) {
$data .= fread(STDIN, 8192);
if ($inputFile) {
$data = file_get_contents($inputFile);

$newWorkingDir = dirname(realpath($inputFile));
$oldWorkingDir = getcwd();

if ($oldWorkingDir !== $newWorkingDir) {
$changeDir = chdir($newWorkingDir);
$inputFile = basename($inputFile);
}
} else {
$data = '';

while (! feof(STDIN)) {
$data .= fread(STDIN, 8192);
}
}

if (has("T")) {
$parser = new Parser("STDIN");
if ($dumpTree) {
$parser = new Parser($inputFile);

print_r($parser->parse($data));
print_r(json_decode(json_encode($parser->parse($data)), true));

exit();
}

$scss = new Compiler();

if (has("f")) {
$scss->setFormatter('Leafo\\ScssPhp\\' . ucfirst($opts["f"]));
if ($debugInfo && $inputFile) {
$scss->setLineNumberStyle(Compiler::DEBUG_INFO);
}

if ($lineNumbers && $inputFile) {
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
}

echo $scss->compile($data, "STDIN");
if ($ignoreErrors) {
$scss->setIgnoreErrors($ignoreErrors);
}

if ($loadPaths) {
$scss->setImportPaths(explode(PATH_SEPARATOR, $loadPaths));
}

if ($precision) {
$scss->setNumberPrecision($precision);
}

if ($style) {
$scss->setFormatter('Leafo\\ScssPhp\\Formatter\\' . ucfirst($style));
}

if ($encoding) {
$scss->setEncoding($encoding);
}

echo $scss->compile($data, $inputFile);

if ($changeDir) {
chdir($oldWorkingDir);
}
62 changes: 0 additions & 62 deletions lib/scssphp/classmap.php

This file was deleted.

Loading