initial commit

This commit is contained in:
2024-04-29 13:12:44 +05:45
commit 34887303c5
19300 changed files with 5268802 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitbc81b8d3181547ae1b045da95a35a2bc::getLoader();

View File

@ -0,0 +1,66 @@
#!/usr/bin/env php
<?php
error_reporting(E_ALL);
include 'scss.inc.php';
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Parser;
$opts = getopt('hvTf:', array('help', 'version'));
function has() {
global $opts;
foreach (func_get_args() as $arg) {
if (isset($opts[$arg])) {
return true;
}
}
return false;
}
if (has("h", "help")) {
$exe = array_shift($argv);
$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
EOT;
exit($HELP);
}
if (has("v", "version")) {
exit(Compiler::$VERSION . "\n");
}
$data = "";
while (!feof(STDIN)) {
$data .= fread(STDIN, 8192);
}
if (has("T")) {
$parser = new Parser("STDIN");
print_r($parser->parse($data));
exit();
}
$scss = new Compiler();
if (has("f")) {
$scss->setFormatter('Leafo\\ScssPhp\\' . ucfirst($opts["f"]));
}
echo $scss->compile($data, "STDIN");

View File

@ -0,0 +1,413 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0 class loader
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-0 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
if ('\\' == $class[0]) {
$class = substr($class, 1);
}
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative) {
return false;
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if ($file === null) {
// Remember that this class does not exist.
return $this->classMap[$class] = false;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) {
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

View File

@ -0,0 +1,16 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'scss_formatter' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_formatter_compressed' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_formatter_crunched' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_formatter_nested' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_parser' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_server' => $vendorDir . '/leafo/scssphp/classmap.php',
'scssc' => $vendorDir . '/leafo/scssphp/classmap.php',
);

View File

@ -0,0 +1,10 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Twig_' => array($vendorDir . '/twig/twig/lib'),
);

View File

@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Leafo\\ScssPhp\\' => array($vendorDir . '/leafo/scssphp/src'),
);

View File

@ -0,0 +1,50 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitbc81b8d3181547ae1b045da95a35a2bc
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitbc81b8d3181547ae1b045da95a35a2bc', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitbc81b8d3181547ae1b045da95a35a2bc', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register(true);
return $loader;
}
}
function composerRequirebc81b8d3181547ae1b045da95a35a2bc($file)
{
require $file;
}

View File

@ -0,0 +1,118 @@
[
{
"name": "leafo/scssphp",
"version": "v0.1.1",
"version_normalized": "0.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/leafo/scssphp.git",
"reference": "8c08da585537e97efd528c7d278463d2b9396371"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/scssphp/zipball/8c08da585537e97efd528c7d278463d2b9396371",
"reference": "8c08da585537e97efd528c7d278463d2b9396371",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"time": "2014-08-12 22:41:53",
"bin": [
"bin/pscss"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"classmap": [
"classmap.php"
],
"psr-4": {
"Leafo\\ScssPhp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "scssphp is a compiler for SCSS written in PHP.",
"homepage": "http://leafo.net/scssphp/",
"keywords": [
"css",
"less",
"sass",
"scss",
"stylesheet"
]
},
{
"name": "twig/twig",
"version": "v1.18.0",
"version_normalized": "1.18.0.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "4cf7464348e7f9893a93f7096a90b73722be99cf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/4cf7464348e7f9893a93f7096a90b73722be99cf",
"reference": "4cf7464348e7f9893a93f7096a90b73722be99cf",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"time": "2015-01-25 17:32:08",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.18-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Twig_": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"role": "Project Founder"
},
{
"name": "Twig Team",
"homepage": "http://twig.sensiolabs.org/contributors",
"role": "Contributors"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"keywords": [
"templating"
]
}
]

View File

@ -0,0 +1,660 @@
For ease of distribution, scssphp is available under a dual license.
You are free to pick which one suits your needs.
* * *
MIT LICENSE
Copyright (c) 2012 Leaf Corcoran, http://leafo.net/scssphp
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* * *
GPL VERSION 3
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

View File

@ -0,0 +1,2 @@
test:
vendor/bin/phpunit --colors tests

View File

@ -0,0 +1,34 @@
# scssphp v0.1.1
### <http://leafo.net/scssphp>
[![Build Status](https://secure.travis-ci.org/leafo/scssphp.png)](http://travis-ci.org/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.
## 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
There are two kinds of 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.
* `InputTest.php` compiles every `.scss` file in the `tests/inputs` directory
then compares to the respective `.css` file in the `tests/outputs` directory.
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
This will compile all the tests, and save results into `tests/outputs`.

View File

@ -0,0 +1,66 @@
#!/usr/bin/env php
<?php
error_reporting(E_ALL);
include 'scss.inc.php';
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Parser;
$opts = getopt('hvTf:', array('help', 'version'));
function has() {
global $opts;
foreach (func_get_args() as $arg) {
if (isset($opts[$arg])) {
return true;
}
}
return false;
}
if (has("h", "help")) {
$exe = array_shift($argv);
$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
EOT;
exit($HELP);
}
if (has("v", "version")) {
exit(Compiler::$VERSION . "\n");
}
$data = "";
while (!feof(STDIN)) {
$data .= fread(STDIN, 8192);
}
if (has("T")) {
$parser = new Parser("STDIN");
print_r($parser->parse($data));
exit();
}
$scss = new Compiler();
if (has("f")) {
$scss->setFormatter('Leafo\\ScssPhp\\' . ucfirst($opts["f"]));
}
echo $scss->compile($data, "STDIN");

View File

@ -0,0 +1,62 @@
<?php
/**
* SCSSPHP
*
* Stub classes for backward compatibility
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
/**
* @deprecated since 0.1.0
*/
class scssc extends \Leafo\ScssPhp\Compiler
{
}
/**
* @deprecated since 0.1.0
*/
class scss_parser extends \Leafo\ScssPhp\Parser
{
}
/**
* @deprecated since 0.1.0
*/
class scss_formatter extends \Leafo\ScssPhp\Formatter\Expanded
{
}
/**
* @deprecated since 0.1.0
*/
class scss_formatter_nested extends \Leafo\ScssPhp\Formatter\Nested
{
}
/**
* @deprecated since 0.1.0
*/
class scss_formatter_compressed extends \Leafo\ScssPhp\Formatter\Compressed
{
}
/**
* @deprecated since 0.1.0
*/
class scss_formatter_crunched extends \Leafo\ScssPhp\Formatter\Crunched
{
}
/**
* @deprecated since 0.1.0
*/
class scss_server extends \Leafo\ScssPhp\Server
{
}

View File

@ -0,0 +1,32 @@
{
"name": "leafo/scssphp",
"type": "library",
"description": "scssphp is a compiler for SCSS written in PHP.",
"keywords": ["css", "stylesheet", "scss", "sass", "less"],
"homepage": "http://leafo.net/scssphp/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"autoload": {
"classmap": ["classmap.php"],
"psr-4": { "Leafo\\ScssPhp\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Leafo\\ScssPhp\\Test\\": "tests/" }
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"bin": ["bin/pscss"]
}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# creates tar.gz for current version
TARGET_DIR="site/www/src"
VERSION=`./pscss -v | sed -n 's/^v\(.*\)$/\1/p'`
OUT_DIR="tmp/scssphp"
TMP=`dirname $OUT_DIR`
mkdir -p $OUT_DIR
tar -c `git ls-files` | tar -C $OUT_DIR -x
rm $OUT_DIR/.gitignore
rm $OUT_DIR/package.sh
rm $OUT_DIR/todo
rm -r $OUT_DIR/site
OUT_PATH="$TARGET_DIR/scssphp-$VERSION.tar.gz"
tar -czf "$OUT_PATH" -C $TMP scssphp/
echo "Wrote $OUT_PATH"
rm -r $TMP

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
strict = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "scss.inc.php">
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -0,0 +1,11 @@
<?php
include __DIR__ . '/src/Colors.php';
include __DIR__ . '/src/Compiler.php';
include __DIR__ . '/src/Formatter.php';
include __DIR__ . '/src/Formatter/Compressed.php';
include __DIR__ . '/src/Formatter/Crunched.php';
include __DIR__ . '/src/Formatter/Expanded.php';
include __DIR__ . '/src/Formatter/Nested.php';
include __DIR__ . '/src/Parser.php';
include __DIR__ . '/src/Server.php';
include __DIR__ . '/classmap.php';

View File

@ -0,0 +1,6 @@
<pre class="highlight lang_json"><code><span class="p">{</span>
<span class="nt">&quot;require&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;leafo/scssphp&quot;</span><span class="p">:</span> <span class="s2">&quot;$current_version&quot;</span>
<span class="p">}</span>
<span class="p">}</span></code>
</pre>

View File

@ -0,0 +1,325 @@
title: Documentation
--
<h1 skip="true">scssphp $current_version Documentation</h1>
<div class="index">$index</div>
## PHP Interface
### Including
The project can be loaded through a `composer` generated auto-loader.
Alternatively, the entire project can be loaded through a utility file.
Just include it somewhere to start using it:
```php
<?php
require "scssphp/scss.inc.php";
```
### Compiling
In order to manually compile code from PHP you must create an instance of the
`Compiler` class. The typical flow is to create the instance, set any compile time
options, then run the compiler with the `compile` method.
```php
<?php
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Compiler;
$scss = new Compiler();
echo $scss->compile('
$color: #abc;
div { color: lighten($color, 20%); }
');
```
* <p>`compile($scssCode)` will attempt to compile a string of SCSS code. If it
succeeds then the CSS will be returned as a string. If there is any error, an
exception is thrown with an appropriate error message.
</p>
### Import Paths
When you import a file using the `@import` directive, the current path of your
PHP script is used as the search path by default. This is often not what
you want, so there are two methods for manipulating the import path:
`addImportPath`, and `setImportPaths`.
* `addImportPath($path)` will append `$path` to the list of the import
paths that are searched.
* `setImportPaths($pathArray)` will replace the entire import path with
`$pathArray`. The value of `$pathArray` will be converted to an array if it
isn't one already.
If the import path is set to `array()` then importing is effectively disabled.
The default import path is `array("")`, which means the current directory.
```php
<?php
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Compiler;
$scss = new Compiler();
$scss->setImportPaths("assets/stylesheets/");
// will search for `assets/stylesheets/mixins.scss'
echo $scss->compile('@import "mixins.scss"');
```
Besides adding static import paths, it's also possible to add custom import
functions. This allows you to load paths from a database, or HTTP, or using
files that SCSS would otherwise not process (such as vanilla CSS imports).
```php
<?php
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Compiler;
$scss = new Compiler();
$scss->addImportPath(function($path) {
if (!file_exists('stylesheets/'.$path)) return null;
return 'stylesheets/'.$path;
});
// will import `stylesheets/vanilla.css'
echo $scss->compile('@import "vanilla.css"');
```
### Output Formatting
It's possible to customize the formatting of the output CSS by changing the
default formatter.
Three formatters are included:
* `Leafo\ScssPhp\Formatter\Expanded`
* `Leafo\ScssPhp\Formatter\Nested` *(default)*
* `Leafo\ScssPhp\Formatter\Compressed`
We can change the formatting using the `setFormatter` method.
* <p>`setFormatter($formatterName)` sets the current formatter to `$formatterName`,
the name of a class as a string that implements the formatting interface. See
the source for `Leafo\ScssPhp\Formatter\Expanded` for an example.
</p>
Given the following SCSS:
```scss
.navigation {
ul {
line-height: 20px;
color: blue;
a {
color: red;
}
}
}
.footer {
.copyright {
color: silver;
}
}
```
The formatters will output,
`Leafo\ScssPhp\Formatter\Expanded`:
```css
.navigation ul {
line-height: 20px;
color: blue;
}
.navigation ul a {
color: red;
}
.footer .copyright {
color: silver;
}
```
`Leafo\ScssPhp\Formatter\Nested`:
```css
.navigation ul {
line-height: 20px;
color: blue; }
.navigation ul a {
color: red; }
.footer .copyright {
color: silver; }
```
`Leafo\ScssPhp\Formatter\Compressed`:
```css
.navigation ul{line-height:20px;color:blue;}.navigation ul a{color:red;}.footer .copyright{color:silver;}
```
### Custom Functions
It's possible to register custom functions written in PHP that can be called
from SCSS. Some possible applications include appending your assets directory
to a URL with an `asset-url` function, or converting image URLs to an embedded
data URI to reduce the number of requests on a page with a `data-uri` function.
We can add and remove functions using the methods `registerFunction` and
`unregisterFunction`.
* `registerFunction($functionName, $callable)` assigns the callable value to
the name `$functionName`. The name is normalized using the rules of SCSS.
Meaning underscores and dashes are interchangeable. If a function with the
same name already exists then it is replaced.
* `unregisterFunction($functionName)` removes `$functionName` from the list of
available functions.
The `$callable` can be anything that PHP knows how to call using
`call_user_func`. The function receives two arguments when invoked. The first
is an array of SCSS typed arguments that the function was sent. The second is a
reference to the current `scss` instance.
The *SCSS typed arguments* are actually just arrays that represent SCSS values.
SCSS has different types than PHP, and this is how **scssphp** represents them
internally.
For example, the value `10px` in PHP would be `array("number", 1, "px")`. There
is a large variety of types. Experiment with a debugging function like `print_r`
to examine the possible inputs.
The return value of the custom function can either be a SCSS type or a basic
PHP type. (such as a string or a number) If it's a PHP type, it will be converted
automatically to the corresponding SCSS type.
As an example, a function called `add-two` is registered, which adds two numbers
together. PHP's anonymous function syntax is used to define the function.
```php
<?php
use Leafo\ScssPhp\Compiler;
$scss = new Compiler();
$scss->registerFunction("add-two", function($args) {
list($a, $b) = $args;
return $a[1] + $b[1];
});
$scss->compile('.ex1 { result: add-two(10, 10); }');
```
It's worth noting that in this example we lose the units of the number, and we
also don't do any type checking. This will have undefined results if we give it
anything other than two numbers.
## SCSS Server
The SCSS server is a small class that helps with automatically compiling SCSS.
It's an endpoint for your web application that searches for SCSS files in a
directory then compiles and serves them as CSS. It will only compile
files if they've been modified (or one of the imports has been modified).
### Using `serveFrom`
`Server::serveFrom` is a simple to use function that should handle most cases.
For example, create a file `style.php`:
```php
<?php
$directory = "stylesheets";
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Server;
Server::serveFrom($directory);
```
Going to the URL `example.com/style.php/style.scss` will attempt to compile
`style.scss` from the `stylesheets` directory, and serve it as CSS.
* <p>`Server::serveFrom($directory)` will serve SCSS files out of
`$directory`. It will attempt to get the path to the file out of
`$_SERVER["PATH_INFO"]`. (It also looks at the GET parameter `p`)
</p>
If it can not find the file it will return an HTTP 404 page:
```text
/* INPUT NOT FOUND scss v0.0.1 */
```
If the file can't be compiled due to an error, then an HTTP 500 page is
returned. Similar to the following:
```text
Parse error: parse error: failed at `height: ;` stylesheets/test.scss on line 8
```
By default , the SCSS server must have write access to the style sheet
directory. It writes its cache in a special directory called `scss_cache`.
Also, because SCSS server writes headers, make sure no output is written before
it runs.
### Using `Leafo\ScssPhp\Server`
Creating an instance of `Server` is just another way of accomplishing what
`serveFrom` does. It lets us customize the cache directory and the instance
of the `Compiler` that is used to compile
* <p>`new Server($sourceDir, $cacheDir, $scss)` creates a new server that
serves files from `$sourceDir`. The cache dir is where the cached compiled
files are placed. When `null`, `$sourceDir . "/scss_cache"` is used. `$scss`
is the instance of `scss` that is used to compile.
</p>
Just call the `serve` method to let it render its output.
Here's an example of creating a SCSS server that outputs compressed CSS:
```php
<?php
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Server;
$scss = new Compiler();
$scss->setFormatter("scss_formatter_compressed");
$server = new Server("stylesheets", null, $scss);
$server->serve();
```
## Command Line Tool
A really basic command line tool is included for integration with scripts. It
is called `pscss`. It reads a SCSS file from standard out and returns the CSS.
If passed the flag `-v`, input is ignored and the current version if returned.
The flag `-f` can be used to set the [formatter](#Output_formatting):
```bash
$ bin/pscss -f scss_formatter_compressed < styles.scss
```

View File

@ -0,0 +1,233 @@
**scssphp** is a compiler for [SCSS][0] written in PHP.
SCSS is a CSS preprocessor that adds many features like variables, mixins,
imports, color manipulation, functions, and tons of other powerful features.
The entire compiler comes in a single class file ready for including in any
kind of project in addition to a command line tool for running the compiler
from the terminal.
**scssphp** implements SCSS (3.2.12). It does not implement the SASS syntax,
only the SCSS syntax.
Follow the author on twitter: [@moonscript](http://twitter.com/moonscript).
<div class="github-buttons">
<iframe src="http://ghbtns.com/github-btn.html?user=leafo&repo=scssphp&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=leafo&repo=scssphp&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95px" height="20px"></iframe>
</div>
<a name="installing"></a>
## Installing
You can always download the latest version here:
<a href="$root/src/scssphp-$current_version.tar.gz" id="download-link">scssphp-$current_version.tar.gz</a>
You can also find the latest source online:
<https://github.com/leafo/scssphp/>
If you use [Packagist][2] for installing packages, then you can update your `composer.json` like so:
$render{[[composer]]}
<a name="quickstart"></a>
## Language Reference
For a complete guide to the syntax of SCSS, consult the [official documentation][1].
## PHP Reference
Complete documentation for **scssphp** is located at <a href="$root/docs/">http://leafo.net/scssphp/docs/</a>.
### Quickstart
If you just want to start serving compiled `scss` files as quick as possible
then start here.
**scssphp** comes with a easy to use class that automatically compiles modified
`scss` files and serves them from a directory you specify.
Create a file, like `style.php`:
```php
<?php
$directory = "stylesheets";
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Server;
Server::serveFrom($directory);
```
Create the directory set in the script alongside the script, then add your
`scss` files to it.
If we've got a file in there called `style.scss`, then we just need to hit the
url: `example.com/style.php/style.scss` to get the compiled css.
If there is an error compiling, the url will result in a `500` error with the
error message. If the file can't be found, then a friendly `404` is returned.
**scssphp** will automatically create a `scss_cache` directory inside the
stylesheets directory where it will cache the compiled output. This way it can
quickly serve the files if no modifications have been made. Your PHP script
must have permission to write in `scss_cache`.
### Compiler Interface
If you're interested in directly using the compiler, then all you need to either
require `scss.inc.php` or use your `composer` generated auto-laoder, and then
invoke the `Compiler` class:
```php
<?php
require "scssphp/scss.inc.php";
use Leafo\ScssPhp\Compiler;
$scss = new Compiler();
echo $scss->compile('
$color: #abc;
div { color: lighten($color, 20%); }
');
```
The `compile` method takes `SCSS` as a string, and returns the `CSS`. If there
is an error when compiling then an exception is thrown with an appropriate
message.
For a more detailed guide consult <a href="$root/docs/">http://leafo.net/scssphp/docs/</a>.
<a name="issues"></a>
## Issues
Find any issues? I'd love to fix them for you, post about them on [the issues tracker][3].
<div id="changelog"></div>
## Changelog
* **0.1.1** -- Aug 12, 2014
* add stub classes -- a backward compatibility layer (vladimmi)
* **0.1.0** -- Aug 9, 2014
* raise PHP requirement (5.3+)
* reformat/reorganize source files to be PSR-2 compliant
* **0.0.15** -- Aug 6, 2014
* fix regression with default values in functions (torkiljohnsen)
* **0.0.14** -- Aug 5, 2014
* @keyframes $name - didn't work inside mixin (sergeylukin)
* Bourbon transform(translateX()) didn't work (dovy and greynor)
* **0.0.13** -- Aug 4, 2014
* handle If-None-Match in client request, and send ETag in response (NSmithUK)
* normalize quotation marks (NoxNebula)
* improve handling of escape sequence in selectors (matt3224)
* add "scss_formatter_crunched" which strips comments
* internal: generate more accurate parse tree
* **0.0.12** -- July 6, 2014
* revert erroneous import-partials-fix (smuuf)
* handle If-Modified-Since in client request, and send Last-Modified in response (braver)
* add hhvm to travis-ci testing
* **0.0.11** -- July 5, 2014
* support multi-line continuation character (backslash)per CSS2.1 and CSS3 spec (caiosm1005)
* imported partials should not be compiled (squarestar)
* add setVariables() and unsetVariable() to interface (leafo/lessphp)
* micro-optimizing is_null() (Yahasana)
* **0.0.10** -- April 14, 2014
* fix media query merging (timonbaetz)
* inline if should treat null as false (wonderslug)
* optimizing toHSL() (jfsullivan)
* **0.0.9** -- December 23, 2013
* fix @for/@while inside @content block (sergeylukin)
* fix functions in mixin_content (timonbaetz)
* fix infinite loop when target extends itself (oscherler)
* fix function arguments are lost inside of @content block
* allow setting number precision (kasperisager)
* add public function helpers (toBool, get, findImport, assertList, assertColor, assertNumber, throwError) (Burgov, atdt)
* add optional cache buster prefix to serve() method (iMoses)
* **0.0.8** -- September 16, 2013
* Avoid IE7 content: counter bug
* Support transparent as color name
* Recursively create cache dir (turksheadsw)
* Fix for INPUT NOT FOUND (morgen32)
* **0.0.7** -- May 24, 2013
* Port various fixes from leafo/lessphp.
* Improve filter precision.
* Parsing large image data-urls does not work.
* Add == and != ops for colors.
* @if and @while directives should treat null like false.
* Add pscss as bin in composer.json (Christian Lück).
* Fix !default bug (James Shannon, Alberto Aldegheri).
* Fix mixin content includes (James Shannon, Christian Brandt).
* Fix passing of varargs to another mixin.
* Fix interpolation bug in expToString() (Matti Jarvinen).
* **0.0.5** -- March 11, 2013
* Better compile time errors
* Fix top level properties inside of a nested `@media` (Anthon Pang)
* Fix some issues with `@extends` (Anthon Pang)
* Enhanced handling of `null` (Anthon Pang)
* Helper functions shouldn't mix with css builtins (Anthon Pang)
* Enhance selector parsing (Guilherme Blanco, Anthon Pang)
* Add Placeholder selector support (Martin Hasoň)
* Add variable argument support (Martin Hasoň)
* Add zip, index, comparable functions (Martin Hasoň)
* A bunch of parser and bug fixes
* **0.0.4** -- Nov 3nd, 2012
* [Import path can be a function](docs/#import_paths) (Christian Lück).
* Correctly parse media queries with more than one item (Christian Lück).
* Add `ie_hex_str`, `abs`, `min`, `max` functions (Martin Hasoň)
* Ignore expressions inside of `calc()` (Martin Hasoň)
* Improve operator evaluation (Martin Hasoň)
* Add [`@content`](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixin-content) support.
* Misc bug fixes.
* **0.0.3** -- August 2nd, 2012
* Add missing and/or/not operators.
* Expression evaluation happens correctly.
* Import file caching and _partial filename support.
* Misc bug fixes.
* **0.0.2** -- July 30th, 2012
* SCSS server is aware of imports
* added custom function interface
* compressed formatter
* wrote <a href="http://leafo.net/scssphp/docs/">documentation</a>
* Initial Release v0.0.1 -- July 29th, 2012
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
(function() {
var changelog = jQuery("#changelog").nextAll("ul:first");
var hidden = changelog.children("li").slice(1).hide();
if (hidden.length) {
var show_all = jQuery("<a href=''>Show All</a>").insertAfter(changelog).on("click", function() {
hidden.show();
show_all.remove();
return false;
});
}
})();
</script>
<a name="comments"></a>
## Comments
<div class="comments" id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'leafo';
var disqus_url = 'http://leafo.net/scssphp/';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
[0]: http://sass-lang.com/
[1]: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#css_extensions
[2]: http://packagist.org/
[3]: https://github.com/leafo/scssphp/issues
[4]: https://github.com/leafo/scssphp/

View File

@ -0,0 +1,15 @@
require "sitegen"
tools = require "sitegen.tools"
sitegen.create_site =>
@current_version = "0.1.1"
@title = "SCSS Compiler in PHP"
scssphp = tools.system_command "bin/pscss < %s > %s", "css"
build scssphp, "style.scss", "style/style.css"
deploy_to "leaf@leafo.net", "www/scssphp/"
add "docs/index.md"

View File

@ -0,0 +1,303 @@
$site_width: 640px;
$light_teal: #7FC7AF;
$teal: desaturate(#3FB8AF, 10%);
$brown: #DAD8A7;
$pink: darken(#FF9E9D, 10%);
$btn_color: desaturate(#FF3D7F, 10%);
::selection {
background: red;
color: white;
}
@mixin unselectable {
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
}
@mixin grad($top, $bottom) {
background-color: mix($top, $bottom);
background-image: linear-gradient(bottom, $bottom 0%, $top 100%);
background-image: -webkit-linear-gradient(bottom, $bottom 0%, $top 100%);
background-image: -moz-linear-gradient(bottom, $bottom 0%, $top 100%);
background-image: -o-linear-gradient(bottom, $bottom 0%, $top 100%);
background-image: -ms-linear-gradient(bottom, $bottom 0%, $top 100%);
}
@mixin autograd($color, $amount: 10%) {
@include grad($color, darken($color, $amount));
}
body {
background: $pink;
font-family: Lato, sans-serif;
}
.header, .footer, .body {
.inner {
width: $site_width;
margin: 0 auto;
}
}
.header {
text-shadow: 0px -1px 0px darken($teal, 15%);
.color {
background: $teal url(../img/tile.png);
border-top: 4px solid $light_teal;
box-shadow: inset 0px 1px 0px rgba(255,255,255, 0.5), inset 0px 8px 8px -8px #37505A, inset 0px -1px 0px rgba(255,255,255, 0.3);
}
h1 {
font-family: 'Quicksand', sans-serif;
font-size: 40px;
line-height: 100px;
font-weight: normal;
margin: 0;
a {
text-decoration: none;
color: #EDFFF9;
&:active {
position: relative;
top: 1px;
}
}
}
.nav {
padding: 8px 0;
font-size: 17px;
text-shadow: none;
background: darken($teal, 30%);
color: $teal;
box-shadow: inset 0px 4px 8px -4px rgba(0,0,0,0.9), inset 0px -1px 0px rgba(255,255,255, 0.8);
a {
color: lighten($teal, 40%);
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.social {
float: right;
margin-top: -2px;
}
}
.download-area {
float: right;
margin-top: 25px;
background: rgba(255,255,255, 0.3);
border-radius: 8px;
padding: 5px;
a {
text-decoration: none;
}
.download-button {
$height: 8px;
$depress: 4px;
@include unselectable;
color: white;
text-align: center;
@include autograd($btn_color);
position: relative;
top: -1 * $height;
padding: 8px 20px;
border-radius: 8px;
text-shadow: none;
box-shadow: 0px $height 0px darken($btn_color, 30%), inset 0px -1px 0px rgba(255,255,255, 0.2), inset 0px 1px 0px rgba(0,0,0, 0.2);
text-shadow: 0px 1px 2px darken($btn_color, 40%);
cursor: pointer;
-webkit-transition: all 0.05s ease-in-out;
-moz-transition: all 0.05s ease-in-out;
transition: all 0.05s ease-in-out;
&:hover {
@include autograd(lighten($btn_color, 3%));
}
&:active {
box-shadow: 0px $height - $depress 0px darken($btn_color, 30%), inset 0px -1px 0px rgba(255,255,255, 0.2), inset 0px 1px 0px rgba(0,0,0, 0.2);
top: -1 * ($height - $depress);
}
.top {
font-weight: bold;
font-size: 16px;
}
.sub {
font-size: 14px;
}
}
}
}
.body {
$bg_color: #FEFFED;
$text_color: darken($brown, 60%);
box-shadow: inset 0px 4px 8px -4px rgba(0,0,0,0.7), inset 0px -4px 8px -4px rgba(0,0,0,0.4);
background: $bg_color;
overflow: hidden;
color: $text_color;
font-size: 18px;
padding-bottom: 20px;
.inner {
background: white;
margin-top: 20px;
padding: 30px 50px;
border: 1px solid lightGrey;
box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.19);
h1, h2, h3 {
margin: 0 0 20px 0;
}
}
h1, h2, h3 {
text-shadow: 1px 1px 0px $bg_color, 2px 2px 0px rgba($text_color, 0.3);
letter-spacing: -1px;
}
h3 {
color: #4D4C3D;
}
p {
margin: 0 0 15px 0;
}
a {
color: #DB1C4A;
&:hover {
color: lighten(#DB1C4A, 10%);
}
}
pre {
margin: 20px 0;
}
}
.footer {
font-size: 16px;
color: lighten($pink, 20%);
text-shadow: 0px 1px 0px darken($pink, 20%);
border-top: 1px dashed darken($pink, 50%);
box-shadow: inset 0px 1px 0px rgba(255,255,255, 0.5);
padding: 8px 0 20px 0;
line-height: 150%;
a {
color: white;
font-weight: bold;
text-decoration: none;
padding: 0 4px;
border-radius: 4px;
border: 1px solid lighten($pink, 4%);
&:hover {
background: darken($pink, 3%);
border: 1px solid lighten($pink, 4%);
}
}
}
p {
line-height: 150%;
code {
background: rgba(0,0,0, 0.1);
border-radius: 4px;
padding: 1px 4px;
}
}
.comments {
font-size: 12px;
}
.index {
line-height: 150%;
margin-bottom: 20px;
ul {
margin: 0;
}
}
.highlight {
background: #333;
color: white;
font-size: 14px;
padding: 10px;
box-shadow: 0px 1px 3px rgba(0,0,0, 0.7), inset 0px 0px 0px 1px rgba(255,255,255,0.3);
border-radius: 2px;
border: 1px solid #222;
// builtins
.nb {
color: #FFA67C;
}
// strings
.s, .s1, .s2, .se, .nt {
color: #ffe898;
}
// proper names
.nc, .vc, .bp {
color: #98d9ff;
}
// true, false, nil
.kc {
color: #acfff0;
}
// function lit, braces, parens
.nf, .kt {
color: #9fff98;
}
.nv {
color: #ff9898;
}
// keywords
.k, .kd, .na {
color: #cb98ff;
}
.c1, .c2 {
color: #929292;
}
.m, .mi, .mf, .mh, .o {
color: #9495ff;
}
}

View File

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$if{"title"}[[$title - ]]scssphp</title>
<link href='http://fonts.googleapis.com/css?family=Lato:400,900|Quicksand' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="$root/style/normalize.css" />
<link rel="stylesheet" href="$root/style/style.css?$generate_date" />
$analytics{"UA-136625-1"}
</head>
<body>
<div class="header">
<div class="color">
<div class="inner">
<div class="download-area">
<a href="$root/src/scssphp-$current_version.tar.gz">
<div class="download-button" id="download-button">
<div class="top">Download</div>
<div class="sub">scssphp-$current_version.tar.gz</div>
</div>
</a>
</div>
<h1><a href="$root">scssphp</a></h1>
</div>
</div>
<div class="nav">
<div class="inner">
<div class="social">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://leafo.net/scssphp/" data-text="scssphp v$current_version - SCSS compiler for PHP" data-count="horizontal" data-via="moonscript">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
<a href="https://twitter.com/moonscript" class="twitter-follow-button" data-width="70px" data-show-count="false" data-show-screen-name="false">Follow @moonscript</a>
</div>
<a href="$root/#installing">Install</a>
&middot;
<a href="$root/#quickstart">Quickstart</a>
&middot;
<a href="$root/docs/">Docs</a>
&middot;
<a href="$root/#comments">Comments</a>
</div>
</div>
</div>
<div class="body">
<div class="inner">
$body
</div>
</div>
<div class="footer">
<div class="inner">
<div>
created by <a href="http://leafo.net">leaf corcoran</a> &middot; scssphp is licensed under GPL3/MIT
</div>
<div>
generated by <a href="http://github.com/leafo/sitegen">sitegen</a> on $generate_date
</div>
</div>
</div>
<script type="text/javascript">
(function() {
document.getElementById("download-button").onclick = function() {
_gaq.push(['_trackEvent', 'scssphp', 'click', 'download-button']);
}
var link = document.getElementById("download-link");
if (link) link.onclick = function() {
_gaq.push(['_trackEvent', 'scssphp', 'click', 'download-link']);
}
})();
</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<a href="https://github.com/leafo/scssphp"><img style="position: fixed; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

View File

@ -0,0 +1,500 @@
/*! normalize.css 2012-07-07T09:50 UTC - http://github.com/necolas/normalize.css */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Corrects `block` display not defined in IE6/7/8/9 & FF3.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
/*
* Corrects `inline-block` display not defined in IE6/7/8/9 & FF3.
*/
audio,
canvas,
video {
display: inline-block;
*display: inline;
*zoom: 1;
}
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/*
* Addresses styling for `hidden` attribute not present in IE7/8/9, FF3, S4.
* Known issue: no IE6 support.
*/
[hidden] {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/*
* 1. Corrects text resizing oddly in IE6/7 when body `font-size` is set using
* `em` units.
* 2. Prevents iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-size: 100%; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
/*
* Addresses `font-family` inconsistency between `textarea` and other form
* elements.
*/
html,
button,
input,
select,
textarea {
font-family: sans-serif;
}
/*
* Addresses margins handled incorrectly in IE6/7.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
========================================================================== */
/*
* Addresses `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/*
* Improves readability when focused and also mouse hovered in all browsers.
* people.opera.com/patrickl/experiments/keyboard/test
*/
a:active,
a:hover {
outline: 0;
}
/* ==========================================================================
Typography
========================================================================== */
/*
* Addresses font sizes and margins set differently in IE6/7.
* Addresses font sizes within `section` and `article` in FF4+, Chrome, S5.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
h2 {
font-size: 1.5em;
margin: 0.83em 0;
}
h3 {
font-size: 1.17em;
margin: 1em 0;
}
h4 {
font-size: 1em;
margin: 1.33em 0;
}
h5 {
font-size: 0.83em;
margin: 1.67em 0;
}
h6 {
font-size: 0.75em;
margin: 2.33em 0;
}
/*
* Addresses styling not present in IE7/8/9, S5, Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/*
* Addresses style set to `bolder` in FF3+, S4/5, Chrome.
*/
b,
strong {
font-weight: bold;
}
blockquote {
margin: 1em 40px;
}
/*
* Addresses styling not present in S5, Chrome.
*/
dfn {
font-style: italic;
}
/*
* Addresses styling not present in IE6/7/8/9.
*/
mark {
background: #ff0;
color: #000;
}
/*
* Addresses margins set differently in IE6/7.
*/
p,
pre {
margin: 1em 0;
}
/*
* Corrects font family set oddly in IE6, S4/5, Chrome.
* en.wikipedia.org/wiki/User:Davidgothberg/Test59
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
_font-family: 'courier new', monospace;
font-size: 1em;
}
/*
* Improves readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
/*
* Addresses CSS quotes not supported in IE6/7.
*/
q {
quotes: none;
}
/*
* Addresses `quotes` property not supported in S4.
*/
q:before,
q:after {
content: '';
content: none;
}
small {
font-size: 75%;
}
/*
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
* gist.github.com/413930
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* ==========================================================================
Lists
========================================================================== */
/*
* Addresses margins set differently in IE6/7.
*/
dl,
menu,
ol,
ul {
margin: 1em 0;
}
dd {
margin: 0 0 0 40px;
}
/*
* Addresses paddings set differently in IE6/7.
*/
menu,
ol,
ul {
padding: 0 0 0 40px;
}
/*
* Corrects list images handled incorrectly in IE7.
*/
nav ul,
nav ol {
list-style: none;
list-style-image: none;
}
/* ==========================================================================
Embedded content
========================================================================== */
/*
* 1. Removes border when inside `a` element in IE6/7/8/9, FF3.
* 2. Improves image quality when scaled in IE7.
* code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/
*/
img {
border: 0; /* 1 */
-ms-interpolation-mode: bicubic; /* 2 */
}
/*
* Corrects overflow displayed oddly in IE9.
*/
svg:not(:root) {
overflow: hidden;
}
/* ==========================================================================
Figures
========================================================================== */
/*
* Addresses margin not present in IE6/7/8/9, S5, O11.
*/
figure {
margin: 0;
}
/* ==========================================================================
Forms
========================================================================== */
/*
* Corrects margin displayed oddly in IE6/7.
*/
form {
margin: 0;
}
/*
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/*
* 1. Corrects color not being inherited in IE6/7/8/9.
* 2. Corrects text not wrapping in FF3.
* 3. Corrects alignment displayed oddly in IE6/7.
*/
legend {
border: 0; /* 1 */
padding: 0;
white-space: normal; /* 2 */
*margin-left: -7px; /* 3 */
}
/*
* 1. Corrects font size not being inherited in all browsers.
* 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome.
* 3. Improves appearance and consistency in all browsers.
*/
button,
input,
select,
textarea {
font-size: 100%; /* 1 */
margin: 0; /* 2 */
vertical-align: baseline; /* 3 */
*vertical-align: middle; /* 3 */
}
/*
* Addresses FF3/4 setting `line-height` on `input` using `!important` in the
* UA stylesheet.
*/
button,
input {
line-height: normal;
}
/*
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Corrects inability to style clickable `input` types in iOS.
* 3. Improves usability and consistency of cursor style between image-type
* `input` and others.
* 4. Removes inner spacing in IE7 without affecting normal text inputs.
* Known issue: inner spacing remains in IE6.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
*overflow: visible; /* 4 */
}
/*
* Re-set default cursor for disabled elements.
*/
button[disabled],
input[disabled] {
cursor: default;
}
/*
* 1. Addresses box sizing set to content-box in IE8/9.
* 2. Removes excess padding in IE8/9.
* 3. Removes excess padding in IE7.
* Known issue: excess padding remains in IE6.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
*height: 13px; /* 3 */
*width: 13px; /* 3 */
}
/*
* 1. Addresses `appearance` set to `searchfield` in S5, Chrome.
* 2. Addresses `box-sizing` set to `border-box` in S5, Chrome (include `-moz`
* to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/*
* Removes inner padding and search cancel button in S5, Chrome on OS X.
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
* Removes inner padding and border in FF3+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/*
* 1. Removes default vertical scrollbar in IE6/7/8/9.
* 2. Improves readability and alignment in all browsers.
*/
textarea {
overflow: auto; /* 1 */
vertical-align: top; /* 2 */
}
/* ==========================================================================
Tables
========================================================================== */
/*
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}

View File

@ -0,0 +1,179 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp;
use Leafo\ScssPhp\Parser;
/**
* CSS Colors
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
class Colors
{
/**
* CSS Colors
*
* @see http://www.w3.org/TR/css3-color
*/
public static $cssColors = array(
'aliceblue' => '240,248,255',
'antiquewhite' => '250,235,215',
'aqua' => '0,255,255',
'aquamarine' => '127,255,212',
'azure' => '240,255,255',
'beige' => '245,245,220',
'bisque' => '255,228,196',
'black' => '0,0,0',
'blanchedalmond' => '255,235,205',
'blue' => '0,0,255',
'blueviolet' => '138,43,226',
'brown' => '165,42,42',
'burlywood' => '222,184,135',
'cadetblue' => '95,158,160',
'chartreuse' => '127,255,0',
'chocolate' => '210,105,30',
'coral' => '255,127,80',
'cornflowerblue' => '100,149,237',
'cornsilk' => '255,248,220',
'crimson' => '220,20,60',
'cyan' => '0,255,255',
'darkblue' => '0,0,139',
'darkcyan' => '0,139,139',
'darkgoldenrod' => '184,134,11',
'darkgray' => '169,169,169',
'darkgreen' => '0,100,0',
'darkgrey' => '169,169,169',
'darkkhaki' => '189,183,107',
'darkmagenta' => '139,0,139',
'darkolivegreen' => '85,107,47',
'darkorange' => '255,140,0',
'darkorchid' => '153,50,204',
'darkred' => '139,0,0',
'darksalmon' => '233,150,122',
'darkseagreen' => '143,188,143',
'darkslateblue' => '72,61,139',
'darkslategray' => '47,79,79',
'darkslategrey' => '47,79,79',
'darkturquoise' => '0,206,209',
'darkviolet' => '148,0,211',
'deeppink' => '255,20,147',
'deepskyblue' => '0,191,255',
'dimgray' => '105,105,105',
'dimgrey' => '105,105,105',
'dodgerblue' => '30,144,255',
'firebrick' => '178,34,34',
'floralwhite' => '255,250,240',
'forestgreen' => '34,139,34',
'fuchsia' => '255,0,255',
'gainsboro' => '220,220,220',
'ghostwhite' => '248,248,255',
'gold' => '255,215,0',
'goldenrod' => '218,165,32',
'gray' => '128,128,128',
'green' => '0,128,0',
'greenyellow' => '173,255,47',
'grey' => '128,128,128',
'honeydew' => '240,255,240',
'hotpink' => '255,105,180',
'indianred' => '205,92,92',
'indigo' => '75,0,130',
'ivory' => '255,255,240',
'khaki' => '240,230,140',
'lavender' => '230,230,250',
'lavenderblush' => '255,240,245',
'lawngreen' => '124,252,0',
'lemonchiffon' => '255,250,205',
'lightblue' => '173,216,230',
'lightcoral' => '240,128,128',
'lightcyan' => '224,255,255',
'lightgoldenrodyellow' => '250,250,210',
'lightgray' => '211,211,211',
'lightgreen' => '144,238,144',
'lightgrey' => '211,211,211',
'lightpink' => '255,182,193',
'lightsalmon' => '255,160,122',
'lightseagreen' => '32,178,170',
'lightskyblue' => '135,206,250',
'lightslategray' => '119,136,153',
'lightslategrey' => '119,136,153',
'lightsteelblue' => '176,196,222',
'lightyellow' => '255,255,224',
'lime' => '0,255,0',
'limegreen' => '50,205,50',
'linen' => '250,240,230',
'magenta' => '255,0,255',
'maroon' => '128,0,0',
'mediumaquamarine' => '102,205,170',
'mediumblue' => '0,0,205',
'mediumorchid' => '186,85,211',
'mediumpurple' => '147,112,219',
'mediumseagreen' => '60,179,113',
'mediumslateblue' => '123,104,238',
'mediumspringgreen' => '0,250,154',
'mediumturquoise' => '72,209,204',
'mediumvioletred' => '199,21,133',
'midnightblue' => '25,25,112',
'mintcream' => '245,255,250',
'mistyrose' => '255,228,225',
'moccasin' => '255,228,181',
'navajowhite' => '255,222,173',
'navy' => '0,0,128',
'oldlace' => '253,245,230',
'olive' => '128,128,0',
'olivedrab' => '107,142,35',
'orange' => '255,165,0',
'orangered' => '255,69,0',
'orchid' => '218,112,214',
'palegoldenrod' => '238,232,170',
'palegreen' => '152,251,152',
'paleturquoise' => '175,238,238',
'palevioletred' => '219,112,147',
'papayawhip' => '255,239,213',
'peachpuff' => '255,218,185',
'peru' => '205,133,63',
'pink' => '255,192,203',
'plum' => '221,160,221',
'powderblue' => '176,224,230',
'purple' => '128,0,128',
'red' => '255,0,0',
'rosybrown' => '188,143,143',
'royalblue' => '65,105,225',
'saddlebrown' => '139,69,19',
'salmon' => '250,128,114',
'sandybrown' => '244,164,96',
'seagreen' => '46,139,87',
'seashell' => '255,245,238',
'sienna' => '160,82,45',
'silver' => '192,192,192',
'skyblue' => '135,206,235',
'slateblue' => '106,90,205',
'slategray' => '112,128,144',
'slategrey' => '112,128,144',
'snow' => '255,250,250',
'springgreen' => '0,255,127',
'steelblue' => '70,130,180',
'tan' => '210,180,140',
'teal' => '0,128,128',
'thistle' => '216,191,216',
'tomato' => '255,99,71',
'transparent' => '0,0,0,0',
'turquoise' => '64,224,208',
'violet' => '238,130,238',
'wheat' => '245,222,179',
'white' => '255,255,255',
'whitesmoke' => '245,245,245',
'yellow' => '255,255,0',
'yellowgreen' => '154,205,50'
);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp;
/**
* SCSS base formatter
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
abstract class Formatter
{
public $indentLevel;
public $indentChar;
public $break;
public $open;
public $close;
public $tagSeparator;
public $assignSeparator;
protected function indentStr($n = 0)
{
return str_repeat($this->indentChar, max($this->indentLevel + $n, 0));
}
public function property($name, $value)
{
return $name . $this->assignSeparator . $value . ';';
}
protected function blockLines($inner, $block)
{
$glue = $this->break.$inner;
echo $inner . implode($glue, $block->lines);
if (!empty($block->children)) {
echo $this->break;
}
}
protected function block($block)
{
if (empty($block->lines) && empty($block->children)) {
return;
}
$inner = $pre = $this->indentStr();
if (!empty($block->selectors)) {
echo $pre .
implode($this->tagSeparator, $block->selectors) .
$this->open . $this->break;
$this->indentLevel++;
$inner = $this->indentStr();
}
if (!empty($block->lines)) {
$this->blockLines($inner, $block);
}
foreach ($block->children as $child) {
$this->block($child);
}
if (!empty($block->selectors)) {
$this->indentLevel--;
if (empty($block->children)) {
echo $this->break;
}
echo $pre . $this->close . $this->break;
}
}
public function format($block)
{
ob_start();
$this->block($block);
$out = ob_get_clean();
return $out;
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter;
/**
* SCSS compressed formatter
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
class Compressed extends Formatter
{
public function __construct()
{
$this->indentLevel = 0;
$this->indentChar = ' ';
$this->break = '';
$this->open = '{';
$this->close = '}';
$this->tagSeparator = ',';
$this->assignSeparator = ':';
}
public function indentStr($n = 0)
{
return '';
}
public function blockLines($inner, $block)
{
$glue = $this->break.$inner;
foreach ($block->lines as $index => $line) {
if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') {
unset($block->lines[$index]);
} elseif (substr($line, 0, 3) === '/*!') {
$block->lines[$index] = '/*' . substr($line, 3);
}
}
echo $inner . implode($glue, $block->lines);
if (!empty($block->children)) {
echo $this->break;
}
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter;
/**
* SCSS crunched formatter
*
* @author Anthon Pang <anthon.pang@gmail.com>
*/
class Crunched extends Formatter
{
public function __construct()
{
$this->indentLevel = 0;
$this->indentChar = ' ';
$this->break = '';
$this->open = '{';
$this->close = '}';
$this->tagSeparator = ',';
$this->assignSeparator = ':';
}
public function indentStr($n = 0)
{
return '';
}
public function blockLines($inner, $block)
{
$glue = $this->break.$inner;
foreach ($block->lines as $index => $line) {
if (substr($line, 0, 2) === '/*') {
unset($block->lines[$index]);
}
}
echo $inner . implode($glue, $block->lines);
if (!empty($block->children)) {
echo $this->break;
}
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter;
/**
* SCSS expanded formatter
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
class Expanded extends Formatter
{
public function __construct()
{
$this->indentLevel = 0;
$this->indentChar = ' ';
$this->break = "\n";
$this->open = ' {';
$this->close = '}';
$this->tagSeparator = ', ';
$this->assignSeparator = ': ';
}
}

View File

@ -0,0 +1,133 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter;
/**
* SCSS nested formatter
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
class Nested extends Formatter
{
public function __construct()
{
$this->indentLevel = 0;
$this->indentChar = ' ';
$this->break = "\n";
$this->open = ' {';
$this->close = ' }';
$this->tagSeparator = ', ';
$this->assignSeparator = ': ';
}
// adjust the depths of all children, depth first
public function adjustAllChildren($block)
{
// flatten empty nested blocks
$children = array();
foreach ($block->children as $i => $child) {
if (empty($child->lines) && empty($child->children)) {
if (isset($block->children[$i + 1])) {
$block->children[$i + 1]->depth = $child->depth;
}
continue;
}
$children[] = $child;
}
$count = count($children);
for ($i = 0; $i < $count; $i++) {
$depth = $children[$i]->depth;
$j = $i + 1;
if (isset($children[$j]) && $depth < $children[$j]->depth) {
$childDepth = $children[$j]->depth;
for (; $j < $count; $j++) {
if ($depth < $children[$j]->depth && $childDepth >= $children[$j]->depth) {
$children[$j]->depth = $depth + 1;
}
}
}
}
$block->children = $children;
// make relative to parent
foreach ($block->children as $child) {
$this->adjustAllChildren($child);
$child->depth = $child->depth - $block->depth;
}
}
protected function blockLines($inner, $block)
{
$glue = $this->break . $inner;
foreach ($block->lines as $index => $line) {
if (substr($line, 0, 2) === '/*') {
$block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line);
}
}
echo $inner . implode($glue, $block->lines);
if (!empty($block->children)) {
echo $this->break;
}
}
protected function block($block)
{
if ($block->type == 'root') {
$this->adjustAllChildren($block);
}
$inner = $pre = $this->indentStr($block->depth - 1);
if (!empty($block->selectors)) {
echo $pre .
implode($this->tagSeparator, $block->selectors) .
$this->open . $this->break;
$this->indentLevel++;
$inner = $this->indentStr($block->depth - 1);
}
if (!empty($block->lines)) {
$this->blockLines($inner, $block);
}
foreach ($block->children as $i => $child) {
// echo "*** block: ".$block->depth." child: ".$child->depth."\n";
$this->block($child);
if ($i < count($block->children) - 1) {
echo $this->break;
if (isset($block->children[$i + 1])) {
$next = $block->children[$i + 1];
if ($next->depth == max($block->depth, 1) && $child->depth >= $next->depth) {
echo $this->break;
}
}
}
}
if (!empty($block->selectors)) {
$this->indentLevel--;
echo $this->close;
}
if ($block->type == 'root') {
echo $this->break;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,315 @@
<?php
/**
* SCSSPHP
*
* @copyright 2012-2014 Leaf Corcoran
*
* @license http://opensource.org/licenses/gpl-license GPL-3.0
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://leafo.net/scssphp
*/
namespace Leafo\ScssPhp;
use Leafo\ScssPhp\Compiler;
/**
* SCSS server
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
class Server
{
/**
* Join path components
*
* @param string $left Path component, left of the directory separator
* @param string $right Path component, right of the directory separator
*
* @return string
*/
protected function join($left, $right)
{
return rtrim($left, '/\\') . DIRECTORY_SEPARATOR . ltrim($right, '/\\');
}
/**
* Get name of requested .scss file
*
* @return string|null
*/
protected function inputName()
{
switch (true) {
case isset($_GET['p']):
return $_GET['p'];
case isset($_SERVER['PATH_INFO']):
return $_SERVER['PATH_INFO'];
case isset($_SERVER['DOCUMENT_URI']):
return substr($_SERVER['DOCUMENT_URI'], strlen($_SERVER['SCRIPT_NAME']));
}
}
/**
* Get path to requested .scss file
*
* @return string
*/
protected function findInput()
{
if (($input = $this->inputName())
&& strpos($input, '..') === false
&& substr($input, -5) === '.scss'
) {
$name = $this->join($this->dir, $input);
if (is_file($name) && is_readable($name)) {
return $name;
}
}
return false;
}
/**
* Get path to cached .css file
*
* @return string
*/
protected function cacheName($fname)
{
return $this->join($this->cacheDir, md5($fname) . '.css');
}
/**
* Get path to meta data
*
* @return string
*/
protected function metadataName($out)
{
return $out . '.meta';
}
/**
* Determine whether .scss file needs to be re-compiled.
*
* @param string $in Input path
* @param string $out Output path
* @param string $etag ETag
*
* @return boolean True if compile required.
*/
protected function needsCompile($in, $out, &$etag)
{
if (! is_file($out)) {
return true;
}
$mtime = filemtime($out);
if (filemtime($in) > $mtime) {
return true;
}
$metadataName = $this->metadataName($out);
if (is_readable($metadataName)) {
$metadata = unserialize(file_get_contents($metadataName));
if ($metadata['etag'] === $etag) {
return false;
}
foreach ($metadata['imports'] as $import) {
if (filemtime($import) > $mtime) {
return true;
}
}
$etag = $metadata['etag'];
return false;
}
return true;
}
/**
* Get If-Modified-Since header from client request
*
* @return string|null
*/
protected function getIfModifiedSinceHeader()
{
$modifiedSince = null;
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$modifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
if (false !== ($semicolonPos = strpos($modifiedSince, ';'))) {
$modifiedSince = substr($modifiedSince, 0, $semicolonPos);
}
}
return $modifiedSince;
}
/**
* Get If-None-Match header from client request
*
* @return string|null
*/
protected function getIfNoneMatchHeader()
{
$noneMatch = null;
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$noneMatch = $_SERVER['HTTP_IF_NONE_MATCH'];
}
return $noneMatch;
}
/**
* Compile .scss file
*
* @param string $in Input path (.scss)
* @param string $out Output path (.css)
*
* @return array
*/
protected function compile($in, $out)
{
$start = microtime(true);
$css = $this->scss->compile(file_get_contents($in), $in);
$elapsed = round((microtime(true) - $start), 4);
$v = Compiler::$VERSION;
$t = @date('r');
$css = "/* compiled by scssphp $v on $t (${elapsed}s) */\n\n" . $css;
$etag = md5($css);
file_put_contents($out, $css);
file_put_contents(
$this->metadataName($out),
serialize(array(
'etag' => $etag,
'imports' => $this->scss->getParsedFiles(),
))
);
return array($css, $etag);
}
/**
* Compile requested scss and serve css. Outputs HTTP response.
*
* @param string $salt Prefix a string to the filename for creating the cache name hash
*/
public function serve($salt = '')
{
$protocol = isset($_SERVER['SERVER_PROTOCOL'])
? $_SERVER['SERVER_PROTOCOL']
: 'HTTP/1.0';
if ($input = $this->findInput()) {
$output = $this->cacheName($salt . $input);
$etag = $noneMatch = trim($this->getIfNoneMatchHeader(), '"');
if ($this->needsCompile($input, $output, $etag)) {
try {
list($css, $etag) = $this->compile($input, $output);
$lastModified = gmdate('D, d M Y H:i:s', filemtime($output)) . ' GMT';
header('Last-Modified: ' . $lastModified);
header('Content-type: text/css');
header('ETag: "' . $etag . '"');
echo $css;
return;
} catch (\Exception $e) {
header($protocol . ' 500 Internal Server Error');
header('Content-type: text/plain');
echo 'Parse error: ' . $e->getMessage() . "\n";
}
}
header('X-SCSS-Cache: true');
header('Content-type: text/css');
header('ETag: "' . $etag . '"');
if ($etag === $noneMatch) {
header($protocol . ' 304 Not Modified');
return;
}
$modifiedSince = $this->getIfModifiedSinceHeader();
$mtime = filemtime($output);
if (@strtotime($modifiedSince) === $mtime) {
header($protocol . ' 304 Not Modified');
return;
}
$lastModified = gmdate('D, d M Y H:i:s', $mtime) . ' GMT';
header('Last-Modified: ' . $lastModified);
echo file_get_contents($output);
return;
}
header($protocol . ' 404 Not Found');
header('Content-type: text/plain');
$v = Compiler::$VERSION;
echo "/* INPUT NOT FOUND scss $v */\n";
}
/**
* Constructor
*
* @param string $dir Root directory to .scss files
* @param string $cacheDir Cache directory
* @param \Leafo\ScssPhp\Compiler|null $scss SCSS compiler instance
*/
public function __construct($dir, $cacheDir = null, $scss = null)
{
$this->dir = $dir;
if (!isset($cacheDir)) {
$cacheDir = $this->join($dir, 'scss_cache');
}
$this->cacheDir = $cacheDir;
if (!is_dir($this->cacheDir)) {
mkdir($this->cacheDir, 0755, true);
}
if (!isset($scss)) {
$scss = new Compiler();
$scss->setImportPaths($this->dir);
}
$this->scss = $scss;
}
/**
* Helper method to serve compiled scss
*
* @param string $path Root path
*/
public static function serveFrom($path)
{
$server = new self($path);
$server->serve();
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace Leafo\ScssPhp\Tests;
use Leafo\ScssPhp\Compiler;
class ApiTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->scss = new Compiler();
}
public function testUserFunction()
{
$this->scss->registerFunction('add-two', function ($args) {
list($a, $b) = $args;
return $a[1] + $b[1];
});
$this->assertEquals(
'result: 30;',
$this->compile('result: add-two(10, 20);')
);
}
public function testImportMissing()
{
$this->assertEquals(
'@import "missing";',
$this->compile('@import "missing";')
);
}
public function testImportCustomCallback()
{
$this->scss->addImportPath(function ($path) {
return __DIR__ . '/inputs/' . str_replace('.css', '.scss', $path);
});
$this->assertEquals(
trim(file_get_contents(__DIR__ . '/outputs/variables.css')),
$this->compile('@import "variables.css";')
);
}
/**
* @dataProvider provideSetVariables
*/
public function testSetVariables($expected, $scss, $variables)
{
$this->scss->setVariables($variables);
$this->assertEquals($expected, $this->compile($scss));
}
public function provideSetVariables()
{
return array(
array(
".magic {\n color: red;\n width: 760px; }",
'.magic { color: $color; width: $base - 200; }',
array(
'color' => 'red',
'base' => '960px',
),
),
array(
".logo {\n color: #808080; }",
'.logo { color: desaturate($primary, 100%); }',
array(
'primary' => '#ff0000',
),
),
);
}
public function compile($str)
{
return trim($this->scss->compile($str));
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace Leafo\ScssPhp\Tests;
use Leafo\ScssPhp\Compiler;
class ExceptionTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->scss = new Compiler();
}
/**
* @param string $scss
* @param string $expectedExceptionMessage
*
* @dataProvider provideScss
*/
public function testThrowError($scss, $expectedExceptionMessage)
{
try {
$this->compile($scss);
} catch (\Exception $e) {
if (strpos($e->getMessage(), $expectedExceptionMessage) !== false) {
return;
};
}
$this->fail('Expected exception to be raised: ' . $expectedExceptionMessage);
}
/**
* @return array
*/
public function provideScss()
{
return array(
array(<<<END_OF_SCSS
.test {
foo : bar;
END_OF_SCSS
,
'unclosed block'
),
array(<<<END_OF_SCSS
.test {
}}
END_OF_SCSS
,
'unexpected }'
),
array(<<<END_OF_SCSS
.test { color: #fff / 0; }
END_OF_SCSS
,
'color: Can\'t divide by zero'
),
array(<<<END_OF_SCSS
.test {
@include foo();
}
END_OF_SCSS
,
'Undefined mixin foo'
),
array(<<<END_OF_SCSS
@mixin do-nothing() {
}
.test {
@include do-nothing(\$a: "hello");
}
END_OF_SCSS
,
'Mixin or function doesn\'t have an argument named $a.'
),
array(<<<END_OF_SCSS
div {
color: darken(cobaltgreen, 10%);
}
END_OF_SCSS
,
'expecting color'
),
);
}
private function compile($str)
{
return trim($this->scss->compile($str));
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace Leafo\ScssPhp\Tests;
use Leafo\ScssPhp\Compiler;
// Runs all the tests in inputs/ and compares their output to ouputs/
function _dump($value)
{
fwrite(STDOUT, print_r($value, true));
}
function _quote($str)
{
return preg_quote($str, '/');
}
class InputTest extends \PHPUnit_Framework_TestCase
{
protected static $inputDir = 'inputs';
protected static $outputDir = 'outputs';
public function setUp()
{
$this->scss = new Compiler();
$this->scss->addImportPath(__DIR__ . '/' . self::$inputDir);
}
/**
* @dataProvider fileNameProvider
*/
public function testInputFile($inFname, $outFname)
{
if (getenv('BUILD')) {
return $this->buildInput($inFname, $outFname);
}
if (!is_readable($outFname)) {
$this->fail("$outFname is missing, consider building tests with BUILD=true");
}
$input = file_get_contents($inFname);
$output = file_get_contents($outFname);
$this->assertEquals($output, $this->scss->compile($input));
}
public function fileNameProvider()
{
return array_map(
function ($a) {
return array($a, InputTest::outputNameFor($a));
},
self::findInputNames()
);
}
// only run when env is set
public function buildInput($inFname, $outFname)
{
$css = $this->scss->compile(file_get_contents($inFname));
file_put_contents($outFname, $css);
}
public static function findInputNames($pattern = '*')
{
$files = glob(__DIR__ . '/' . self::$inputDir . '/' . $pattern);
$files = array_filter($files, 'is_file');
if ($pattern = getenv('MATCH')) {
$files = array_filter($files, function ($fname) use ($pattern) {
return preg_match("/$pattern/", $fname);
});
}
return $files;
}
public static function outputNameFor($input)
{
$front = _quote(__DIR__ . '/');
$out = preg_replace("/^$front/", '', $input);
$in = _quote(self::$inputDir . '/');
$out = preg_replace("/$in/", self::$outputDir . '/', $out);
$out = preg_replace("/.scss$/", '.css', $out);
return __DIR__ . '/' . $out;
}
public static function buildTests($pattern)
{
$files = self::findInputNames($pattern);
foreach ($files as $file) {
}
}
}

View File

@ -0,0 +1,25 @@
#!/bin/bash
diff_tool="$1"
for file in $(ls inputs/*.scss); do
out_file=$(echo $file | sed -e 's/inputs/outputs/' -e 's/\.scss$/\.css/')
sass=$(scss < $file 2> /dev/null)
if [ $? = "0" ]; then
# echo $file
# echo "$sass"
# echo
if [ "$(cat $out_file)" != "$sass" ]; then
echo "* [FAIL] $file"
if [ -n "$diff_tool" ]; then
$diff_tool $out_file <(echo "$sass") 2> /dev/null
fi
else
echo " [PASS] $file"
fi
else
echo " $file"
fi
done

View File

@ -0,0 +1,171 @@
#color {
color: rgb(34,234,24);
red: red(rgb(34,234,24));
green: green(rgb(34,234,24));
blue: blue(rgb(34,234,24));
color: rgba(1,2,4, 0.5);
a1: alpha(rgb(1,2,4));
a2: alpha(rgba(1,2,4, 0.5));
mix: mix(rgb(1,2,3), rgb(3,4,5));
rgba: rgba($color: #a7c, $alpha: 0.4);
rgba: rgba(#a7c, 0.4);
}
#hsl {
color: hsl(100, 50, 55);
color: hsla(100, 50, 55, 0.5);
hue: hue(hsl(100, 50, 55));
sat: saturation(hsl(100, 50, 55));
lig: lightness(hsl(100, 50, 55));
}
#more-color {
$color: hsl(-80,44,33);
light: lighten($color, 10%);
dark: darken($color, 10%);
sat: saturate($color, 10%);
desat: desaturate($color, 10%);
gray: grayscale($color);
comp: complement($color);
inv: invert($color);
}
#more-more-color {
$color: rgba(1,2,3,0.5);
op: opacity($color);
opacify: opacify($color, 0.1);
opacify: fade-in($color, 0.1);
transparentize: transparentize($color, 0.1);
transparentize: fade-out($color, 0.1);
transparentize: transparentize(#348203, 0.1);
}
#more-more-more-color {
$color: rgba(10,10,10,0);
color: adjust-color($color, $blue: 69, $red: 55, $green: 100, $alpha: 0.4);
color: adjust-color($color, $hue: 170, $saturation: 100, $lightness: 50);
color: change-color($color, $blue: 69, $red: 55, $green: 100, $alpha: 0.4);
color: change-color($color, $hue: 170, $saturation: 100, $lightness: 50);
color: scale-color($color, $red: 55%);
color: scale-color($color, $red: -55%);
color: scale-color($color, $lightness: 55%);
color: scale-color($color, $lightness: -55%);
color: ie-hex-str($color);
color: ie-hex-str(#abc);
}
#string {
color: unquote("hello what is going on");
// color: quote(yeah you know it); // **
color: quote(yeah);
color: quote("I do?");
}
#number {
color: percentage(100/40);
color: round(3.4);
color: floor(3.4);
color: ceil(3.4);
top: floor(10.4px);
top: ceil(.4ex);
width: percentage(100px / 50px);
bottom: abs(-10px);
padding: min(5em, 3em, 4em) max(2px, 1in) min(1in, 96px) max(1in, 72pt);
}
#list {
len: length(hello world what);
len: length(thing);
n: nth(hello world what, 1);
// n: nth(hello world what, 100); // **
hello: join(one two three, hello, comma);
hello: join(one two three, hello world what is going, comma);
hello: append(one two three, hello, comma);
index: index(1px solid red, solid);
index: index(1px solid red, dashed);
index: index(1px solid red, #f00);
index: index(96px solid red, 1in);
index: index((1in 2) a b, 1in);
index: index((1in 2) a b, (96px 2));
index: index((1in 2) a b, (1in, 2));
index: index((1px solid red), solid);
index: index(1px 3px + 3px, 4+2px);
$var: oo;
index: index(foo bar, f#{$var});
$yes: one, two, three;
$no: great job;
world: join($yes, $no);
world: append($yes, $no);
cool: join($yes, $no, space);
cool: join($no, $yes);
zip: zip((1px, 2px), (solid dashed));
zip: zip(1px 2px 3px, solid dashed, red green blue);
}
#introspection {
t: type-of(100px);
t: type-of(asdf);
t: type-of("asdf");
t: type-of(true);
t: type-of(#fff);
t: type-of(blue);
t: type-of(one two three);
u: unit(12);
u: unit(12px);
u: unit(12em);
l: unitless(23);
l: unitless(23deg);
c: comparable(2px, 1px);
c: comparable(100px, 3em);
c: comparable(10cm, 3mm);
c: comparable(1, 4);
c: comparable(1ex, 4em);
c: comparable(2em, 5em);
}
#if {
color: if(true, yes, no);
color: if(false, yes, no);
color: if(false or true, yes, no);
color: if(10px, yes, no);
}
.transparent {
r: red(transparent);
g: green(transparent);
b: blue(transparent);
a: alpha(transparent);
}
.alpha {
a: alpha(black);
a: alpha(#fff);
a: alpha(rgb(0, 0, 0));
a: alpha(rgba(0, 0, 0, 0.5));
a: alpha(currentColor);
}

View File

@ -0,0 +1,44 @@
// what is going on?
/** what the heck **/
/**
Here is a block comment
**/
// this is a comment
// trailing backslash \
/*hello*/div /*yeah*/ { //surew
border: 1px solid red; // world
/* another property */
color: url('http://mage-page.com');
string: "hello /* this is not a comment */";
world: "// neither is this";
string: 'hello /* this is not a comment */' /*what if this is a comment */;
world: '// neither is this' // hell world;
;
what-ever: 100px;
background: url(/*this is not a comment?*/); // uhh what happens here
}
// begin
.dummy {
color: blue;
}
/* comment 1 */
a {
/* comment 2 */
/* comment 3 */ color: red; /* comment 4 */
background-color: red; /* comment 5 */
/* comment 6 */
}
/* comment 7 */
// end

View File

@ -0,0 +1,248 @@
// Extracted from compass/typography/vertical_rhythm.scss
// The base font size.
$base-font-size: 16px !default;
// The base line height determines the basic unit of vertical rhythm.
$base-line-height: 24px !default;
// Set the default border style for rhythm borders.
$default-rhythm-border-style: solid !default;
// The default font size in all browsers.
$browser-default-font-size: 16px;
// Set to false if you want to use absolute pixels in sizing your typography.
$relative-font-sizing: true !default;
// Allows the `adjust-font-size-to` mixin and the `lines-for-font-size` function
// to round the line height to the nearest half line height instead of the
// nearest integral line height to avoid large spacing between lines.
$round-to-nearest-half-line: false !default;
// Ensure there is at least this many pixels
// of vertical padding above and below the text.
$min-line-padding: 2px !default;
// $base-font-size but in your output unit of choice.
// Defaults to 1em when `$relative-font-sizing` is true.
$font-unit: if($relative-font-sizing, 1em, $base-font-size) !default;
// The basic unit of font rhythm.
$base-rhythm-unit: $base-line-height / $base-font-size * $font-unit;
// The leader is the amount of whitespace in a line.
// It might be useful in your calculations.
$base-leader: ($base-line-height - $base-font-size) * $font-unit / $base-font-size;
// The half-leader is the amount of whitespace above and below a line.
// It might be useful in your calculations.
$base-half-leader: $base-leader / 2;
// True if a number has a relative unit.
@function relative-unit($number) {
@return unit($number) == "%" or unit($number) == "em" or unit($number) == "rem"
}
// True if a number has an absolute unit.
@function absolute-unit($number) {
@return not (relative-unit($number) or unitless($number));
}
@if $relative-font-sizing and not relative-unit($font-unit) {
@warn "$relative-font-sizing is true but $font-unit is set to #{$font-unit} which is not a relative unit.";
}
// Establishes a font baseline for the given font-size.
@mixin establish-baseline($font-size: $base-font-size) {
// IE 6 refuses to resize fonts set in pixels and it weirdly resizes fonts
// whose root is set in ems. So we set the root font size in percentages of
// the default font size.
* html {
font-size: 100% * ($font-size / $browser-default-font-size);
}
html {
font-size: $font-size;
@include adjust-leading-to(1, if($relative-font-sizing, $font-size, $base-font-size));
}
}
// Resets the line-height to 1 vertical rhythm unit.
// Does not work on elements whose font-size is different from $base-font-size.
//
// @deprecated This mixin will be removed in the next release.
// Please use the `adjust-leading-to` mixin instead.
@mixin reset-baseline {
@include adjust-leading-to(1, if($relative-font-sizing, $base-font-size, $base-font-size));
}
// Show a background image that can be used to debug your alignments.
// Include the $img argument if you would rather use your own image than the
// Compass default gradient image.
@mixin debug-vertical-alignment($img: false) {
@if $img {
background: image-url($img);
} @else {
@include baseline-grid-background($base-rhythm-unit);
}
}
// Adjust a block to have a different font size and line height to maintain the
// rhythm. $lines specifies how many multiples of the baseline rhythm each line
// of this font should use up. It does not have to be an integer, but it
// defaults to the smallest integer that is large enough to fit the font.
// Use $from-size to adjust from a font-size other than the base font-size.
@mixin adjust-font-size-to($to-size, $lines: lines-for-font-size($to-size), $from-size: $base-font-size) {
@if not $relative-font-sizing and $from-size != $base-font-size {
@warn "$relative-font-sizing is false but a relative font size was passed to adjust-font-size-to";
}
font-size: $font-unit * $to-size / $from-size;
@include adjust-leading-to($lines, if($relative-font-sizing, $to-size, $base-font-size));
}
// Adjust a block to have different line height to maintain the rhythm.
// $lines specifies how many multiples of the baseline rhythm each line of this
// font should use up. It does not have to be an integer, but it defaults to the
// smallest integer that is large enough to fit the font.
@mixin adjust-leading-to($lines, $font-size: $base-font-size) {
line-height: rhythm($lines, $font-size);
}
// Calculate rhythm units.
@function rhythm(
$lines: 1,
$font-size: $base-font-size,
$offset: 0
) {
@if not $relative-font-sizing and $font-size != $base-font-size {
@warn "$relative-font-sizing is false but a relative font size was passed to the rhythm function";
}
$rhythm: $font-unit * ($lines * $base-line-height - $offset) / $font-size;
// Round the pixels down to nearest integer.
@if unit($rhythm) == px {
$rhythm: floor($rhythm);
}
@return $rhythm;
}
// Calculate the minimum multiple of rhythm units needed to contain the font-size.
@function lines-for-font-size($font-size) {
$lines: if($round-to-nearest-half-line,
ceil(2 * $font-size / $base-line-height) / 2,
ceil($font-size / $base-line-height));
@if $lines * $base-line-height - $font-size < $min-line-padding * 2 {
$lines: $lines + if($round-to-nearest-half-line, 0.5, 1);
}
@return $lines;
}
// Apply leading whitespace. The $property can be margin or padding.
@mixin leader($lines: 1, $font-size: $base-font-size, $property: margin) {
#{$property}-top: rhythm($lines, $font-size);
}
// Apply leading whitespace as padding.
@mixin padding-leader($lines: 1, $font-size: $base-font-size) {
padding-top: rhythm($lines, $font-size);
}
// Apply leading whitespace as margin.
@mixin margin-leader($lines: 1, $font-size: $base-font-size) {
margin-top: rhythm($lines, $font-size);
}
// Apply trailing whitespace. The $property can be margin or padding.
@mixin trailer($lines: 1, $font-size: $base-font-size, $property: margin) {
#{$property}-bottom: rhythm($lines, $font-size);
}
// Apply trailing whitespace as padding.
@mixin padding-trailer($lines: 1, $font-size: $base-font-size) {
padding-bottom: rhythm($lines, $font-size);
}
// Apply trailing whitespace as margin.
@mixin margin-trailer($lines: 1, $font-size: $base-font-size) {
margin-bottom: rhythm($lines, $font-size);
}
// Shorthand mixin to apply whitespace for top and bottom margins and padding.
@mixin rhythm($leader: 0, $padding-leader: 0, $padding-trailer: 0, $trailer: 0, $font-size: $base-font-size) {
@include leader($leader, $font-size);
@include padding-leader($padding-leader, $font-size);
@include padding-trailer($padding-trailer, $font-size);
@include trailer($trailer, $font-size);
}
// Apply a border and whitespace to any side without destroying the vertical
// rhythm. The whitespace must be greater than the width of the border.
@mixin apply-side-rhythm-border($side, $width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
@if not $relative-font-sizing and $font-size != $base-font-size {
@warn "$relative-font-sizing is false but a relative font size was passed to apply-side-rhythm-border";
}
border-#{$side}: {
style: $border-style;
width: $font-unit * $width / $font-size;
};
padding-#{$side}: rhythm($lines, $font-size, $offset: $width);
}
// Apply borders and whitespace equally to all sides.
@mixin rhythm-borders($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
@if not $relative-font-sizing and $font-size != $base-font-size {
@warn "$relative-font-sizing is false but a relative font size was passed to rhythm-borders";
}
border: {
style: $border-style;
width: $font-unit * $width / $font-size;
};
padding: rhythm($lines, $font-size, $offset: $width);
}
// Apply a leading border.
@mixin leading-border($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
@include apply-side-rhythm-border(top, $width, $lines, $font-size, $border-style);
}
// Apply a trailing border.
@mixin trailing-border($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
@include apply-side-rhythm-border(bottom, $width, $lines, $font-size, $border-style);
}
// Apply both leading and trailing borders.
@mixin horizontal-borders($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
@include leading-border($width, $lines, $font-size, $border-style);
@include trailing-border($width, $lines, $font-size, $border-style);
}
// Alias for `horizontal-borders` mixin.
@mixin h-borders($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
@include horizontal-borders($width, $lines, $font-size, $border-style);
}
#test-0 {
unit: relative-unit(10px);
unit: relative-unit(50%);
rhythm: rhythm();
size: lines-for-font-size(15px);
size: lines-for-font-size(16px);
size: lines-for-font-size(17px);
size: lines-for-font-size(27px);
size: lines-for-font-size(37px);
}
#test-1 {
@include rhythm(5, 6, 7);
}
#test-2 {
@include rhythm-borders;
}
#test-3 {
@include horizontal-borders;
}

View File

@ -0,0 +1,61 @@
@mixin apply-to-ie6-only {
* html {
@content;
}
}
@include apply-to-ie6-only {
#logo {
background-image: url(/logo.gif);
}
}
$color: white;
@mixin colors($color: blue) {
background-color: $color;
@content;
border-color: $color;
}
.colors {
@include colors { color: $color; }
}
@mixin iphone {
@media only screen and (max-width: 480px) {
@content;
}
}
@include iphone {
body { color: red }
}
#sidebar {
$sidebar-width: 300px;
width: $sidebar-width;
@include iphone {
width: $sidebar-width / 3;
}
}
@mixin respond-to($width) {
@media only screen and (min-width: $width) { @content; }
}
@include respond-to(40em) {
@for $i from 1 through 2 {
.grid-#{$i} { width: 100%; }
}
}
@include respond-to(40em) {
$i: 1;
@while $i <= 2 {
.grid-#{$i} { width: 100%; }
$i: $i + 1;
}
}

View File

@ -0,0 +1,17 @@
$test-var: true;
@mixin mixin-using-content() {
@content;
}
@function test-function($value) {
@return $value;
}
@include mixin-using-content {
@if $test-var {
body {
padding: test-function(1 px);
}
}
}

View File

@ -0,0 +1,15 @@
@mixin cool($color: blue) {
margin: 100px;
}
@function what($height: red) {
@return $height;
}
div {
height: what();
@include cool;
}

View File

@ -0,0 +1,108 @@
@charset "hello-world";
@page :left {
div {
color: red;
}
}
@page test {
@media yes {
div {
color: red;
}
@media no {
pre {
color: blue;
}
}
}
}
@media something {
@page {
@media else {
div {
height: 200px;
}
}
}
}
div {
color: red;
@page yeah {
pre {
height: 20px;
}
}
}
@font-face {
color: red;
height: 20px;
}
@keyframes 'bounce' {
from {
top: 100px;
animation-timing-function: ease-out;
}
25% {
top: 50px;
animation-timing-function: ease-in;
}
50% {
top: 100px;
animation-timing-function: ease-out;
}
75% {
top: 75px;
animation-timing-function: ease-in;
}
to {
top: 100px;
}
}
@-webkit-keyframes flowouttoleft {
0% { -webkit-transform: translateX(0) scale(1); }
60%, 70% { -webkit-transform: translateX(0) scale(.7); }
100% { -webkit-transform: translateX(-100%) scale(.7); }
}
div {
animation-name: 'diagonal-slide';
animation-duration: 5s;
animation-iteration-count: 10;
}
@keyframes 'diagonal-slide' {
from {
left: 0;
top: 0;
}
to {
left: 100px;
top: 100px;
}
}
@document url(http://www.w3.org/),
url-prefix(http://www.w3.org/Style/),
domain(mozilla.org),
regexp("https:.*")
{
body { color: purple; background: yellow; }
}

View File

@ -0,0 +1,184 @@
error, other {
border: 1px #f00;
background-color: #fdd;
}
pre, span {
seriousError {
@extend error;
font-size: 20px;
}
}
hello {
@extend other;
color: green;
div {
margin: 10px;
}
}
.cool {
color: red;
}
.blue {
color: purple;
}
.me {
@extend .cool, .blue;
}
.hoverlink { @extend a:hover }
a:hover { text-decoration: underline }
// partial matching and selector merging:
div.hello.world.hmm {
color: blue;
}
pre, code {
.okay.span {
@extend .hello;
}
}
// multiple matches per selector
.xxxxx .xxxxx .xxxxx {
color: green;
}
code {
@extend .xxxxx;
color: red;
}
// chained
.alpha {
color: red;
}
.beta {
@extend .alpha;
color: white;
}
.gama {
@extend .beta;
color: blue;
}
// merging selector sequences
#admin .tabbar a {font-weight: bold}
#demo .overview .fakelink {@extend a}
a1 b1 c1 d1 { color: red; }
x1 y1 z1 w1 { @extend a1; }
a2 b2 c2 d2 { color: red; }
x2 y2 z2 w2 { @extend b2; }
a3 b3 c3 d3 { color: red; }
x3 y3 z3 w3 { @extend c3; }
a4 b4 c4 d4 { color: red; }
x4 y4 z4 w4 { @extend d4; }
// removing common prefix
#butt .yeah .okay { font-weight: bold }
#butt .umm .sure { @extend .okay }
a9 b9 s9 t9 v9 { color: red; }
a9 b9 x9 y9 z9 {
@extend v9;
}
// extends & media
@media print {
horse {
color: blue;
}
}
man {
color: red;
@extend horse;
}
// result == match
wassup {
color: blue;
@extend wassup;
}
.foo {
.wassup {
@extend .wassup;
color: blue;
}
}
// multi-extend
#something {
color: red;
}
.x {
@extend #something;
}
.y {
@extend #something;
}
// twitter-sass-bootstrap infinite loop
.nav-tabs {
&.nav-justified {
@extend .nav-justified;
}
}
.nav-justified {
text-align: justify;
}
// multi-extend with nesting
.btn:hover,
.btn:active,
.btn.active,
.btn.disabled,
.btn[disabled] {
color: red;
}
.edit .actions {
button {
float: right;
@extend .btn;
}
}
.edit {
.new {
.actions {
padding: 0;
}
.actions button {
@extend .btn;
}
}
}

View File

@ -0,0 +1,48 @@
#number {
-webkit-filter: grayscale(1)
sepia(0.5)
saturate(0.1)
invert(1)
opacity(0.5)
brightness(0.5)
contrast(0.5);
}
#percentage {
-webkit-filter: grayscale(100%)
sepia(50%)
saturate(10%)
invert(100%)
opacity(50%)
brightness(50%)
contrast(50%);
}
#misc {
-webkit-filter: hue-rotate(90deg)
blur(10px)
drop-shadow(10px -16px 30px purple);
}
@mixin opacity($opacity, $style: 0) {
@if ($opacity < 1) {
opacity: $opacity;
filter: alpha(opacity=$opacity * 100, style=$style);
} @else {
opacity: $opacity / 100;
filter: alpha(opacity=$opacity);
}
}
#decimal {
@include opacity(.5, 1);
}
#percent {
@include opacity(50);
}
.row {
background-color: darken(#2ba6cb, 40%);
color: darken(#2ba6cb, 10%);
}

View File

@ -0,0 +1,89 @@
@function hello($x) {
@return $x + 4;
}
@function add($a, $b) {
@return $a + $b;
}
div {
color: hello(10px);
sum: add(11, 12);
}
// make sure values are being reduced before being passed up to previous scope
@function one($a, $b) {
@return $a $b;
}
@function two($a, $b) {
@return $a#{$a} $b;
}
@function three($a, $b: default) {
@return "hello #{$a} and #{$b}"
}
@function all($a...) {
@return "hello #{$a}"
}
div {
hello: one(10, 55);
hello: two(10, 55);
hello: three(10, 55);
}
@function hello_world() {
@return 1000;
}
del {
color: hello-world();
}
div {
$args: foo bar;
hello: three($args...);
hello: three(bar...);
hello: all(Alice, Bob, Tom);
}
@function stringConcatCompassStyle($start,$last)
{
// Compass still uses it like this
@return #{$start}-#{$last};
}
.foo
{
test2: stringConcatCompassStyle(-moz,art);
}
@mixin content_test {
span {
$color: green;
@content;
}
}
@function func_test($c) {
@return $c + 1;
}
div {
@include content_test {
height: func_test(2px);
}
}
@function test ($a, $b: $a/2) {
@return $b;
}
div {
width: test(4);
}

View File

@ -0,0 +1,12 @@
// http://jes.st/2013/ie7s-css-breaking-content-counter-bug/
#foo:before {
content: counter(item, ".") ": ";
}
#bar:before {
content: counter(item,".");
}
#fu:before {
content: counter(item);
}

View File

@ -0,0 +1,76 @@
@function conds($val) {
@if $val {
@return "red";
}
@return "blue";
}
div {
@if something {
color: blue;
}
}
pre {
val-1: conds(true);
val-2: conds(false);
val-3: conds(null);
val-4: conds(1);
val-5: conds(0);
}
span {
@if false {
color: red;
} @else {
color: blue;
}
@if true {
height: 10px;
} @else {
color: 20px;
}
@if false {
height: 10px;
} @elseif false {
color: 20px;
} @else {
width: 20px;
}
}
div {
@if false {
color: red;
} @else if false {
color: green;
} @else {
color: blue;
}
@if false {
border-color: red;
} @else if true {
border-color: green;
} @else {
border-color: blue;
}
}
// doesn't work in scss, thing loses scope
del {
@if false {
$thing: yes;
} @else {
$thing: no;
}
thing: $thing;
}

View File

@ -0,0 +1,8 @@
@function testfunc($pseudo: null) {
$output: if($pseudo, "green", "red");
@return $output;
}
body {
background-color: testfunc();
}

View File

@ -0,0 +1,23 @@
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
@import "imports/simple";
pre {
color: red;
@import "imports/simple.scss";
}
code {
@import "imports/simple", "imports/simple";
}
@import "imports/partial";
body {
color: $variable;
@include partial-mixin();
}

View File

@ -0,0 +1,10 @@
#partial {
color: blue;
}
$variable: #7C2;
@mixin partial-mixin() {
background: gray;
}

View File

@ -0,0 +1,4 @@
div {
height: 200px;
color: red;
}

View File

@ -0,0 +1,86 @@
div {
color: red#{white} blue;
color: red #{white} blue;
color: red #{white}blue;
color: red#{white}blue;
color: #{umm}#{yeah}#{what};
color: #{stacked};
font-size: 10px/#{something};
font-size: 10px / #{something};
test: "what#{"world"}wrong";
test: "what#{'world'}wrong";
test: "what#{world}wrong";
test: "what"#{world}"wrong";
hi: "what is #{4 + 12} end"
}
// interpolation in selectors
pre {
$var: cool;
#{var} {
color: red;
}
#{var} dad {
color: red;
}
bed#{var}dad {
color: red;
}
}
cool {
@for $x from 1 through 5 {
.thing-#{$x} {
color: red;
}
}
}
a#{b}c#{d}e {
color: red;
}
##{hello}, .#{world}{
color: red;
}
#abc#{hello}yeah, .cool#{world}yes{
color: red;
}
$scope: 2;
div.element:nth-child(#{$scope}n)
{
display: none;
}
// property interpolation
div {
$var: hello;
#{$var}: world;
cool#{$var}:world;
#{$var}one:world;
two#{$var}one:world;
one#{a + b}two: cool;
#{hello}: {
#{world}: red;
#{mold}: white;
#{$var}: blue;
}
}

View File

@ -0,0 +1,24 @@
// mixins
@mixin hello($a: one, $b:two, $c:three, $d: four) {
out: $a $b $c $d;
}
pre {
@include hello(alpha, $d: palace, $b: fort);
}
// functions
@function cool($a, $b) {
@return $a - $b;
}
div {
hello: cool($b: 5, $a: 10);
world: cool(5, 10);
}

View File

@ -0,0 +1,15 @@
$list: (black);
$list: join($list, white, comma);
div {
padding: join(10px 20px, 30px 40px);
margin: join((0, 10px), (10px, 10px), space);
background: linear-gradient($list);
}
$list: ();
$list: join($list, (red, blue), comma);
p {
background: linear-gradient($list);
}

View File

@ -0,0 +1,51 @@
div {
@each $var in what is this {
color: $var;
}
@each $var in what, is, this {
font: $var;
}
$list: what is this;
@each $var in $list {
background: $var;
}
$list: what, is, this;
@each $var in $list {
border: $var;
}
}
span {
$i: 0;
@while $i <= 10 {
color: $i;
$i: $i + 1;
}
}
pre {
@for $x from 1 to 5 {
color: $x;
}
@for $x from 1 through 5 {
height: $x;
}
$y: 10;
@for $x from $y through 3 {
cool: $x;
}
}
$j: null;
@while $j {
.item { width: 2em; }
$j: false;
}

View File

@ -0,0 +1,208 @@
// media syntax
@media {
div { color: blue; }
}
@media what {
div { color: blue; }
}
@media (cool) {
div { color: blue; }
}
@media (cool: blue) {
div { color: blue; }
}
@media hello and (world) and (butt: man) {
div { color: blue; }
}
$navbarCollapseWidth: 940px;
@media (max-width: $navbarCollapseWidth) {
color: red;
}
// media bubbling
@media not hello and (world) {
color: blue;
pre {
color: blue;
}
@media butt {
color: red;
div {
color: red;
}
}
}
@media a, b {
@media c {
color: blue;
}
}
@media a{
@media b, c {
color: blue;
}
}
@media a, b{
@media c, d {
color: blue;
}
}
$media: cree;
$feature: -webkit-min-device-pixel-ratio;
$value: 1.5;
div {
color: blue;
@media s#{$media}n and ($feature: $value) {
.sidebar {
width: 500px;
}
}
}
// @media + @mixin
@mixin color {
color: red;
.success {
color: green;
}
}
div {
position: absolute;
$y: 2em;
@media screen {
top: 0;
$x: 5px;
p {
margin: $x;
}
bottom: 6em + $y;
@include color;
}
}
.button {
width: 300px;
height: 100px;
background: #eee;
:hover {
background: #aaa;
}
@media only screen and (max-width : 300px){
width: 100px;
height: 100px;
}
}
code {
position: absolute;
@media screen {
pre {
height: 20px;
}
height: 10px;
}
}
dt {
@media screen {
@media (color: blue) {
height: 10px;
}
}
}
// nesting media queries
@media screen {
.screen {
width: 12px;
}
@media only screen {
.only-screen {
height: 11px;
}
}
}
@media only screen {
.only-screen {
width: 14px;
}
@media only screen {
.only-screen {
height: 16px;
}
}
}
@media not screen {
@media screen {
.invalid {
height: 12px;
}
}
}
@media not screen {
@media print {
.only-print {
height: 12px;
}
}
}
@media screen {
@media not print {
.only-print {
height: 12px;
}
}
}
@media not screen {
@media not print {
.invalid {
height: 12px;
}
}
}
@media not screen {
@media not screen {
.not-screen {
height: 15px;
}
}
}
@media only screen {
@media print {
.invalid {
height: 15px;
}
}
}
@media only screen {
@media screen and (color: blue) {
@media screen and (width: 13) {
.only-screen {
height: 15px;
}
}
}
}

View File

@ -0,0 +1,183 @@
@mixin something {
color: red;
pre {
height: 200px;
}
}
div {
color: blue;
@include something;
}
@mixin something($color) {
color: $color;
div {
height: 20px;
}
}
@mixin cool($a, $b, $c) {
height: $a + $b + $c;
}
span {
@include something(blue);
}
html {
@include cool(10px, 12px, 21px);
}
@mixin hello_world {
height: 20px;
}
del {
@include hello-world;
}
// variable shadowing
$color: white;
@mixin colors($color: blue) {
color: $color;
}
div {
color: $color;
@include colors();
color: $color;
}
@mixin linear-gradient($from, $to, $pos: left top) {
background-image: linear-gradient($pos, $from, $to);
}
div {
@include linear-gradient(red, green);
}
@mixin box-shadow($shadows...) {
-moz-box-shadow: $shadows;
-webkit-box-shadow: $shadows;
box-shadow: $shadows;
}
div {
@include box-shadow(10px 10px 5px #888);
@include box-shadow(inset 10px 10px #888, -10px -10px #f4f4f4);
}
@mixin nested {
@include something(red);
}
div {
p {
.class {
@include nested;
}
@include nested;
.top {
top: 0;
div {
color: red;
}
}
color: blue;
}
}
// mixin content (http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixin-content)
@mixin content-simple {
div.mixin-content-simple {
@content;
}
}
@mixin content-with-arg ( $background ) {
div.mixin-content-with-arg {
background: $background;
@content;
}
}
@include content-simple {
color: red;
}
@include content-with-arg($background: blue) {
color: red;
}
@include content-with-arg($background: purple) {
@include hello_world;
}
@include content-simple {
@include cool(10px, 12px, 21px);
}
@include content-simple {
@include something(orange);
}
@include content-with-arg($background: purple) {
@include cool(10px, 12px, 21px);
}
@include content-with-arg($background: purple) {
@include something(orange);
}
@mixin wallpaper($image, $top: 0, $right: 0, $bottom: 0, $left: 0) {
background: $image;
position: absolute;
top: $top;
right: $right;
bottom: $bottom;
left: $left;
}
@mixin logo($offsets...) {
@include wallpaper(url(/images/logo.png), $offsets...);
}
#please-wait {
@include logo(1em, $left: 4em, $bottom: 3em);
}
@mixin prefixer($property, $value) {
-webkit-#{$property}: $value;
}
@mixin transform($property: none) {
@include prefixer(transform, $property);
}
div.parameter-name-scope {
@include transform(translateX(50px));
}
@mixin keyframes( $name )
{
@-webkit-keyframes $name {
@content;
}
}
@include keyframes( change-color )
{
0% { color: green; }
100% { color: red; }
}

View File

@ -0,0 +1,45 @@
body {
color: red;
}
div {
color: red;
height: yes;
pre {
color: blue;
}
}
div: blue;
div {
font: 10px hello world {
size: 10px;
color: blue;
}
border: {
left: 1px solid blue;
right: 2px dashed green;
}
}
#nested-nesting {
bar: baz;
bang: {
bop: bar;
bip: 1px;
blat: {
baf: bort
}
}
}

View File

@ -0,0 +1,41 @@
$list: null;
.div {
one: null;
one: null world;
one: NULL world;
one: a null, b;
two: a $list $list, $list, b;
three: $list;
}
$value: null;
p:before {
content: "I ate #{$value} pies!";
}
@mixin Rounded($radius1, $direction: null, $radius2: false) {
$corner: null;
@if $direction == TL { $corner: top-left-; }
@if $direction == TR { $corner: top-right-; }
@if $direction == BL { $corner: bottom-left-; }
@if $direction == BR { $corner: bottom-right-; }
@if $radius2 {
-webkit-border-#{$corner}radius: $radius1 $radius2;
border-#{$corner}radius: $radius1 $radius2;
} @else {
-webkit-border-#{$corner}radius: $radius1;
border-#{$corner}radius: $radius1;
}
}
.foo {
@include Rounded(10);
}
.fu {
@include Rounded(20, null);
}
.bar {
@include Rounded(30, TL);
}

View File

@ -0,0 +1,143 @@
body {
color: 1 + 2 + 5;
color: 1 + 2 * 5 + 5;
height: 10px/10px;
color: 10px/2 + 1;
color: (10px/2);
bottom: (4/2px);
top: 1em * (1 * 24px - 0) / 16px;
left: 1 - 2cm;
top: (2cm/12px);
}
div {
color: 4 == 3;
color: hello == hello;
color: 4 > 3;
color: 4 < 3;
color: what > 3;
}
#units {
test: 1in + 4cm;
test: 12mm + 1;
test: 1 + 3em;
test: 1mm + 1cm;
test: 1cm + 1mm;
}
#modulo {
test: 3 % 2;
test: 4cm % 3;
}
#colors {
color: red + rgb(1,2,3);
color: red - rgb(1,2,3);
color: rgba(1,2,3, 0.5) * rgba(3,4,5, 0.5);
color: rgba(10,15,20, 0.5) / rgba(2,2,2, 0.5);
color: rgba(1,2,3, 0.5) * 2;
color: rgba(1,2,3, 0.5) / 2;
color: rgba(1,2,3, 0.5) + 2;
color: rgba(1,2,3, 0.5) - 2;
color: blue + 34;
color: #fff == #000;
color: #fff == #fff;
color: #fff != #000;
color: #fff != #fff;
}
#preserve {
hello: what -going;
hello: what - going;
}
#strings {
hello: what -going;
hello: what +going;
hello: what+going;
hello: what+ going;
hello: what + going;
hello: "what" + going;
hello: going + "what";
hello: "what" + "what";
}
#negation {
$num: 100;
a: -$num + 40;
b: 10 -$num;
b: 10 - $num;
}
#bools-fail {
and: false and two;
and: one and two;
and: one and false;
or: false or two;
or: one or two;
or: one or false;
}
#bools {
and: (false and two);
and: (one and two);
and: (one and false);
or: (false or two);
or: (one or two);
or: (one or false);
}
#nots-fail {
not: not true + 2;
not: not false;
not: not 0;
not: not 1;
not: not "";
not: not hello;
}
#nots {
not: (not true) + 2;
not: (not false);
not: (not 0);
not: (not 1);
not: (not "");
not: (not hello);
}
#string-test {
str: hi == "hi";
str: hi == "no";
str: 'yes' == 'yes';
$var1: "hello";
$var2: hello;
str: "#{$var1}" == '#{$var2}';
str: xhello#{$var1}x == "x#{$var2}hellox"; // xhellohellofalse
str: unit(10px) == px;
}
#special {
cancel-unit: (10px / 10px);
}

View File

@ -0,0 +1,59 @@
/* comment 1 */
a {
/* comment 2 */
color: red; /* comment 3 */
/* comment 4 */
}
/* comment 5 */
/*! comment 1 */
b {
/*! comment 2 */
color: red; /*! comment 3 */
/*! comment 4 */
}
/*! comment 5 */
/*
* multi-line comment 1
*/
c {
/*
* multi-line comment 2
*/
color: red; /*
* multi-line comment 3
*/
/*
* multi-line comment 4
*/
}
/*
* multi-line comment 5
*/
/*!
* multi-line comment 1
*/
d {
/*!
* multi-line comment 2
*/
color: red; /*!
* multi-line comment 3
*/
/*!
* multi-line comment 4
*/
}
/*!
* multi-line comment 5
*/
// comment 1
e {
// comment 2
color: red; // comment 3
// comment 4
}
// comment 5

View File

@ -0,0 +1,18 @@
#context a%extreme span {
color: blue;
font-weight: bold;
font-size: 2em;
}
.notice, .error { @extend %extreme; }
.hidden %placeholder {
margin: 0;
}
p {
@extend #context;
padding: 2em;
}
div { @extend .hidden; }

View File

@ -0,0 +1,986 @@
[foo~=bar] {
a: b; }
[foo^=bar] {
a: b; }
[foo$=bar] {
a: b; }
[foo*=bar] {
a: b; }
[foo|=en] {
a: b; }
foo {
a: 2;
b: 2.3em;
c: 50%;
d: "fraz bran";
e: flanny-blanny-blan;
f: url(http://sass-lang.com);
// g: U+ffa?;
h: #aabbcc; }
selector {
property: value;
property2: value; }
sel{p:v}
.foo {
/* Foo
Bar
Baz */
a: b; }
.foo {
/* Foo
Bar
Baz */
a: b; }
.foo {/* Foo
Bar */
a: b; }
.foo {/* Foo
Bar
Baz */
a: b; }
@foo {
rule {
a: b; }
a: b; }
@foo {a:b};
@bar {a:b};
@foo "bar"
foo {
a: 12px calc(100%/3 - 2*1em - 2*1px);
b: 12px -moz-calc(100%/3 - 2*1em - 2*1px);
b: 12px -webkit-calc(100%/3 - 2*1em - 2*1px);
b: 12px -foobar-calc(100%/3 - 2*1em - 2*1px); }
foo {bar: baz}
<!--
bar {bar: baz}
-->
baz {bar: baz}
/*
* foo
*/
bar {baz: bang}
E, F {
a: b; }
E F, G H {
a: b; }
E > F, G > H {
a: b; }
/* This is a CSS comment. */
.one {color: green;} /* Another comment */
/* The following should not be used:
.two {color: red;} */
.three {color: green; /* color: red; */}
/**
.four {color: red;} */
.five {color: green;}
/**/
.six {color: green;}
/*********/
.seven {color: green;}
/* a comment **/
.eight {color: green;}
foo {
a: \foo bar;
b: foo\ bar;
c: \2022 \0020;
d: foo\\bar;
e: foo\"\'bar; }
foo {
a: "\foo bar";
b: "foo\ bar";
c: "\2022 \0020";
d: "foo\\bar";
e: "foo\"'bar"; }
foo {
_name: val;
*name: val;
:name: val;
.name: val;
#name: val;
name/**/: val;
name/*\**/: val;
name: val; }
@foo "bar" ;
foo {
a: -moz-element(#foo);
b: -webkit-element(#foo);
b: -foobar-element(#foo); }
@foo {}
@foo {
}
@foo;
foo {;;;;
bar: baz;;;;
;;}
#foo .bar {}
#foo .bar {
}
0% {
a: b; }
60% {
a: b; }
100% {
a: b; }
12px {
a: b; }
"foo" {
a: b; }
foo {
a: 12px expression(1 + (3 / Foo.bar("baz" + "bang") + function() {return 12;}) % 12); }
:foo("bar") {
a: b; }
:foo(bar) {
a: b; }
:foo(12px) {
a: b; }
:foo(+) {
a: b; }
:foo(-) {
a: b; }
:foo(+"bar") {
a: b; }
:foo(-++--baz-"bar"12px) {
a: b; }
foo {
a: foo-bar(12);
b: -foo-bar-baz(13, 14 15); }
@import "foo.css";
@import 'foo.css';
@import url("foo.css");
@import url('foo.css');
@import url(foo.css);
@import "foo.css" screen;
@import "foo.css" screen, print;
@import "foo.css" screen, print and (foo: 0);
@import "foo.css" screen, only print, screen and (foo: 0);
foo {
a: foo !important;
b: foo bar !important;
b: foo, bar !important; }
foo {
a: -moz-bar-baz;
b: foo -o-bar-baz; }
foo {a: /* b; c: */ d}
foo {a /*: b; c */: d}
/* Foo
* Bar */
.foo {
/* Foo
* Bar */ }
[foo] {
a: b; }
[foo="bar"] {
a: b; }
[foo~="bar"] {
a: b; }
[foo^="bar"] {
a: b; }
[foo$="bar"] {
a: b; }
[foo*="bar"] {
a: b; }
[foo|="en"] {
a: b; }
:root {
a: b; }
:nth-child(n) {
a: b; }
:nth-last-child(n) {
a: b; }
:nth-of-type(n) {
a: b; }
:nth-last-of-type(n) {
a: b; }
:first-child {
a: b; }
:last-child {
a: b; }
:first-of-type {
a: b; }
:last-of-type {
a: b; }
:only-child {
a: b; }
:only-of-type {
a: b; }
:empty {
a: b; }
:link {
a: b; }
:visited {
a: b; }
:active {
a: b; }
:hover {
a: b; }
:focus {
a: b; }
:target {
a: b; }
:lang(fr) {
a: b; }
:enabled {
a: b; }
:disabled {
a: b; }
:checked {
a: b; }
::first-line {
a: b; }
::first-letter {
a: b; }
::before {
a: b; }
::after {
a: b; }
.warning {
a: b; }
#myid {
a: b; }
:not(s) {
a: b; }
@media all {
rule1 {
prop: val; }
rule2 {
prop: val; } }
@media screen, print {
rule1 {
prop: val; }
rule2 {
prop: val; } }
@media screen and (-webkit-min-device-pixel-ratio:0) {
a: b; }
@media only screen, print and (foo: 0px) and (bar: flam(12px solid)) {
a: b; }
:-moz-any(h1, h2, h3) {
a: b; }
:-moz-any(.foo) {
a: b; }
:-moz-any(foo bar, .baz > .bang) {
a: b; }
@-moz-document url(http://www.w3.org/),
url-prefix(http://www.w3.org/Style/),
domain(mozilla.org),
regexp("^https:.*") {
.foo {a: b}
}
foo {
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000000);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000000); }
foo {
filter: alpha(opacity=20);
filter: alpha(opacity=20, enabled=true);
filter: blaznicate(foo=bar, baz=bang bip, bart=#fa4600); }
@foo bar {
a: b; }
@bar baz {
c: d; }
@foo bar;
@bar baz;
/* Foo
* Bar */
/* Baz
* Bang */
.foo {
/* Foo
* Bar */
/* Baz
* Bang */ }
.foo {
/* Foo Bar *//* Baz Bang */ }
@namespace "http://www.w3.org/Profiles/xhtml1-strict";
@namespace url(http://www.w3.org/Profiles/xhtml1-strict);
@namespace html url("http://www.w3.org/Profiles/xhtml1-strict");
[foo|bar=baz] {
a: b; }
[*|bar=baz] {
a: b; }
[foo|bar|=baz] {
a: b; }
foo|E {
a: b; }
*|E {
a: b; }
foo|* {
a: b; }
*|* {
a: b; }
:not(foo|bar) {
a: b; }
:not(*|bar) {
a: b; }
:not(foo|*) {
a: b; }
:not(*|*) {
a: b; }
:not(#blah) {
a: b; }
:not(.blah) {
a: b; }
:not([foo]) {
a: b; }
:not([foo^="bar"]) {
a: b; }
:not([baz|foo~="bar"]) {
a: b; }
:not(:hover) {
a: b; }
:not(:nth-child(2n + 3)) {
a: b; }
:not(:not(#foo)) {
a: b; }
:not(a#foo.bar) {
a: b; }
:not(#foo .bar > baz) {
a: b; }
:not(h1, h2, h3) {
a: b; }
@mixin foo {
a: b; }
foo {
a: "bang #{1 + " bar "} bip"; }
:nth-child(-n) {
a: b; }
:nth-child(+n) {
a: b; }
:nth-child(even) {
a: b; }
:nth-child(odd) {
a: b; }
:nth-child(50) {
a: b; }
:nth-child(-50) {
a: b; }
:nth-child(+50) {
a: b; }
:nth-child(2n+3) {
a: b; }
:nth-child(2n-3) {
a: b; }
:nth-child(+2n-3) {
a: b; }
:nth-child(-2n+3) {
a: b; }
:nth-child(-2n+ 3) {
a: b; }
:nth-child( 2n + 3 ) {
a: b; }
foo {
a: foo bar baz;
b: foo, #aabbcc, -12;
c: 1px/2px/-3px;
d: foo bar, baz/bang; }
@page {
prop1: val;
prop2: val; }
@page flap {
prop1: val;
prop2: val; }
@page :first {
prop1: val;
prop2: val; }
@page flap:first {
prop1: val;
prop2: val; }
.foo {
/* Foo */
a: b; }
.foo {
/* Foo
* Bar */a: b; }
/* Foo */
.foo {
a: b; }
/* Foo
* Bar */.foo {
a: b; }
.foo /* .a #foo */ #bar:baz(/* bang )*/ bip) {
a: b; }
> E {
a: b; }
+ E {
a: b; }
~ E {
a: b; }
> > E {
a: b; }
>> E {
a: b; }
E* {
a: b; }
E*.foo {
a: b; }
E*:hover {
a: b; }
E,
F {
a: b; }
E
F {
a: b; }
E, F
G, H {
a: b; }
body {
/*
//comment here
*/
}
E>F { a: b;}
E~F { a: b;}
E+F { a: b;}
* {
a: b; }
E {
a: b; }
E[foo] {
a: b; }
E[foo="bar"] {
a: b; }
E[foo~="bar"] {
a: b; }
E[foo^="bar"] {
a: b; }
E[foo$="bar"] {
a: b; }
E[foo*="bar"] {
a: b; }
E[foo|="en"] {
a: b; }
E:root {
a: b; }
E:nth-child(n) {
a: b; }
E:nth-last-child(n) {
a: b; }
E:nth-of-type(n) {
a: b; }
E:nth-last-of-type(n) {
a: b; }
E:first-child {
a: b; }
E:last-child {
a: b; }
E:first-of-type {
a: b; }
E:last-of-type {
a: b; }
E:only-child {
a: b; }
E:only-of-type {
a: b; }
E:empty {
a: b; }
E:link {
a: b; }
E:visited {
a: b; }
E:active {
a: b; }
E:hover {
a: b; }
E:focus {
a: b; }
E:target {
a: b; }
E:lang(fr) {
a: b; }
E:enabled {
a: b; }
E:disabled {
a: b; }
E:checked {
a: b; }
E::first-line {
a: b; }
E::first-letter {
a: b; }
E::before {
a: b; }
E::after {
a: b; }
E.warning {
a: b; }
E#myid {
a: b; }
E:not(s) {
a: b; }
E F {
a: b; }
E > F {
a: b; }
E + F {
a: b; }
E ~ F {
a: b; }
@supports (a: b) and (c: d) or (not (d: e)) and ((not (f: g)) or (not ((h: i) and (j: k)))) {
.foo {
a: b;
}
}
@-prefix-supports (a: b) and (c: d) or (not (d: e)) and ((not (f: g)) or (not ((h: i) and (j: k)))) {
.foo {
a: b;
}
}
foo {
foo: bar;
#baz: bang;
#bip: bop; }
foo {
a: -2;
b: -2.3em;
c: -50%;
d: -foo(bar baz); }
foo {
a: -0.5em;
b: +0.5em;
c: -foo(12px);
d: +foo(12px);
}
@charset "UTF-8";
foo {
-moz-foo-bar: blat;
-o-flat-blang: wibble; }
foo {
a: foo();
b: bar baz-bang() bip; }

View File

@ -0,0 +1,195 @@
* { color: blue; }
E { color: blue; }
E:not(:link) { color: blue; }
E:not(:link):not(:visited) { color: blue; }
E:not(:link, :visited) { color: blue; }
E:matches(:hover, :focus) { color: blue; }
E.warning { color: blue; }
E#id { color: blue; }
E[foo] { color: blue; }
E[foo="barbar"] { color: blue; }
E[foo="barbar" i] { color: blue; }
E[foo~="hello#$@%@$#^"] { color: blue; }
E[foo^="color: green;"] { color: blue; }
E[foo$="239023"] { color: blue; }
E[foo*="29302"] { color: blue; }
E[foo|="239032"] { color: blue; }
[foo] { color: blue; }
[foo] .helloWorld { color: blue; }
[foo].helloWorld { color: blue; }
[foo="barbar"] { color: blue; }
[foo~="hello#$@%@$#^"] { color: blue; }
[foo^="color: green;"] { color: blue; }
[foo$="239023"] { color: blue; }
[foo*="29302"] { color: blue; }
[foo|="239032"] { color: blue; }
E:dir(ltr) { color: blue; }
E:lang(en) { color: blue; }
E:lang(en, fr) { color: blue; }
E:any-link { color: blue; }
E:link { color: blue; }
E:visited { color: blue; }
E:local-link { color: blue; }
E:local-link(0) { color: red; }
E:local-link(1) { color: white; }
E:local-link(2) { color: red; }
E:target { color: blue; }
E:scope { color: blue; }
E:current { color: blue; }
E:current(:link) { color: blue; }
E:past { color: blue; }
E:future { color: blue; }
E:active { color: blue; }
E:hover { color: blue; }
E:focus { color: blue; }
E:enabled { color: blue; }
E:disabled { color: blue; }
E:indeterminate { color: blue; }
E:default { color: blue; }
E:in-range { color: blue; }
E:out-of-range { color: blue; }
E:required { color: blue; }
E:optional { color: blue; }
E:read-only { color: blue; }
E:read-write { color: blue; }
E:root { color: blue; }
E:empty { color: blue; }
E:first-child { color: blue; }
E:nth-child(odd) { color: blue; }
E:nth-child(2n+1) { color: blue; }
E:nth-child(5) { color: blue; }
E:last-child { color: blue; }
E:nth-last-child(-n+2) { color: blue; }
E:only-child { color: blue; }
E:first-of-type { color: blue; }
E:nth-of-type(2n) { color: blue; }
E:last-of-type { color: blue; }
E:nth-last-of-type(n) { color: blue; }
E:only-of-type { color: blue; }
E:nth-match(odd) { color: blue; }
E:nth-last-match(odd) { color: blue; }
E:column(n) { color: blue; }
E:nth-column(n) { color: blue; }
E:nth-last-column(n) { color: blue; }
E F { color: blue; }
E > F { color: blue; }
E + F { color: blue; }
E ~ F { color: blue; }
E /foo/ F { color: blue; }
E! > F { color: blue; }
// namespaces
[foo|att=val] { color: blue }
[*|att] { color: yellow }
[|att] { color: green }
[att] { color: green }
// CSS2.1
E::first-line { color: blue; }
E::first-letter { color: blue; }
E::before { color: blue; }
E::after { color: blue; }
// CSS3 UI (at risk)
E::choices { color: blue; }
E::value { color: blue; }
E::repeat-index { color: blue; }
E::repeat-item { color: blue; }
E:first { color: blue; }
E:first-line { color: blue; }
E:first-letter { color: blue; }
E:before{ color: blue; }
E:after { color: blue; }
E:checked { color: blue; }
E:invalid { color: blue; }
E:valid { color: blue; }
E:left { color: blue; }
E:right { color: blue; }
// -moz experimental
E:any(ol) { color: blue; }
E::selection { color: blue; }
// one of these is nested property,
// the other is a css block.
div {
font:something {
size: 30em;
}
font: something {
size: 30em;
}
}
// self selector
.something {
&.world {
color: blue;
}
& .mold {
height: 200px;
}
.dog & {
color: blue;
}
}
.simple {
.dad & .wolf {
color: blue;
}
.rad&.bad {
color: blue;
}
}
div {
.something & .what {
&.world {
color: blue;
}
}
}
div {
&.foo & {
color: blue;
}
}
.main, div {
.message div {
.title {
.nice-fonts & {
font-size: 24px;
}
}
}
}
$name: escape;
.#{$name}\% {
color: red;
}
.escape-plan\% {
color: green;
}

View File

@ -0,0 +1,43 @@
#values {
color: #eee;
color: #eeeeee;
height: 20px;
width: 80%;
color: "hello world";
height: url("http://google.com");
dads: url(http://leafo.net);
padding: 10px 10px 10px 10px, 3px 3px 3px;
textblock: "This is a \
multiline block \
#not { color: #eee;}";
margin: 4,3,1;
content: "This is a \
multiline string.";
border-radius: -1px -1px -1px black;
}
#subtraction {
lit: 10 -11;
lit: 10 - 11;
lit: 10- 11;
lit: 10-11;
$num: 100;
var: 10 -$num;
var: 10 - $num;
var: 10- $num;
var: 10-$num;
}
#special {
a: 12px expression(1 + (3 / Foo.bar("baz" + "bang") + function() {return 12;}) % 12);
}
#unary {
b: +0.5em;
c: -foo(12px);
d: +foo(12px);
}

View File

@ -0,0 +1,56 @@
$color: red, two, three;
div {
height: $color;
}
$a: 1000;
div {
$a: 2000 !default;
num: $a;
}
div {
$b: 2000 !default;
num: $b;
}
$cool_color: null;
$cool_color: blue !default;
pre {
color: $cool_color;
}
$something_man: 100px;
cool: $something_man;
del {
$something: blue;
div {
$something: red;
pre {
color: $something;
}
}
color: $something;
}
$font-family-simple: Arial !default;
$font-family-spaces: Helvetica Neue !default;
$font-family-quotes: "Helvetica Neue" !default;
$font-family-commas: Helvetica, Arial, sans-serif !default;
$font-family-sans: "Helvetica Neue", Helvetica, Arial, sans-serif !default;
body {
font-family: $font-family-simple;
font-family: $font-family-spaces;
font-family: $font-family-quotes;
font-family: $font-family-commas;
font-family: $font-family-sans;
}

View File

@ -0,0 +1,126 @@
#color {
color: #22ea18;
red: 34;
green: 234;
blue: 24;
color: rgba(1, 2, 4, 0.5);
a1: 1;
a2: 0.5;
mix: #020304;
rgba: rgba(170, 119, 204, 0.4);
rgba: rgba(170, 119, 204, 0.4); }
#hsl {
color: #79c653;
color: rgba(121, 198, 83, 0.5);
hue: 100deg;
sat: 50%;
lig: 55%; }
#more-color {
light: #7e3d9e;
dark: #432154;
sat: #632782;
desat: #5e3871;
gray: #545454;
comp: #48792f;
inv: #9fd086; }
#more-more-color {
op: 0.5;
opacify: rgba(1, 2, 3, 0.6);
opacify: rgba(1, 2, 3, 0.6);
transparentize: rgba(1, 2, 3, 0.4);
transparentize: rgba(1, 2, 3, 0.4);
transparentize: rgba(52, 130, 3, 0.9); }
#more-more-more-color {
color: rgba(65, 110, 79, 0.4);
color: rgba(20, 255, 216, 0);
color: rgba(55, 100, 69, 0.4);
color: rgba(0, 255, 213, 0);
color: rgba(145, 10, 10, 0);
color: rgba(5, 10, 10, 0);
color: rgba(145, 145, 145, 0);
color: rgba(5, 5, 5, 0);
color: #000A0A0A;
color: #FFAABBCC; }
#string {
color: hello what is going on;
color: "yeah";
color: "I do?"; }
#number {
color: 250%;
color: 3;
color: 3;
color: 4;
top: 10px;
top: 1ex;
width: 200%;
bottom: 10px;
padding: 3em 1in 96px 72pt; }
#list {
len: 3;
len: 1;
n: hello;
hello: one, two, three, hello;
hello: one, two, three, hello, world, what, is, going;
hello: one, two, three, hello;
index: 2;
index: false;
index: 3;
index: 1;
index: false;
index: 1;
index: false;
index: 2;
index: 2;
index: 1;
world: one, two, three, great, job;
world: one, two, three, great job;
cool: one two three great job;
cool: great job one two three;
zip: 1px solid, 2px dashed;
zip: 1px solid red, 2px dashed green; }
#introspection {
t: number;
t: string;
t: string;
t: bool;
t: color;
t: color;
t: list;
u: "";
u: "px";
u: "em";
l: true;
l: false;
c: true;
c: false;
c: true;
c: true;
c: false;
c: true; }
#if {
color: yes;
color: no;
color: yes;
color: yes; }
.transparent {
r: 0;
g: 0;
b: 0;
a: 0; }
.alpha {
a: 1;
a: 1;
a: 1;
a: 0.5;
a: alpha(currentColor); }

View File

@ -0,0 +1,31 @@
/** what the heck **/
/**
Here is a block comment
**/
/*hello*/
div {
/*yeah*/
border: 1px solid red;
/* another property */
color: url('http://mage-page.com');
string: "hello /* this is not a comment */";
world: "// neither is this";
string: 'hello /* this is not a comment */';
/*what if this is a comment */
world: '// neither is this';
what-ever: 100px;
background: url();
/*this is not a comment?*/ }
.dummy {
color: blue; }
/* comment 1 */
a {
/* comment 2 */
/* comment 3 */
color: red;
/* comment 4 */
background-color: red;
/* comment 5 */
/* comment 6 */ }
/* comment 7 */

View File

@ -0,0 +1,28 @@
#test-0 {
unit: false;
unit: true;
rhythm: 1.5em;
size: 1;
size: 1;
size: 1;
size: 2;
size: 2; }
#test-1 {
margin-top: 7.5em;
padding-top: 9em;
padding-bottom: 10.5em;
margin-bottom: 0em; }
#test-2 {
border-style: solid;
border-width: 0.0625em;
padding: 1.4375em; }
#test-3 {
border-top-style: solid;
border-top-width: 0.0625em;
padding-top: 1.4375em;
border-bottom-style: solid;
border-bottom-width: 0.0625em;
padding-bottom: 1.4375em; }

View File

@ -0,0 +1,29 @@
* html #logo {
background-image: url(/logo.gif); }
.colors {
background-color: blue;
color: white;
border-color: blue; }
@media only screen and (max-width: 480px) {
body {
color: red; } }
#sidebar {
width: 300px; }
@media only screen and (max-width: 480px) {
#sidebar {
width: 100px; } }
@media only screen and (min-width: 40em) {
.grid-1 {
width: 100%; }
.grid-2 {
width: 100%; } }
@media only screen and (min-width: 40em) {
.grid-1 {
width: 100%; }
.grid-2 {
width: 100%; } }

View File

@ -0,0 +1,3 @@
div {
height: red;
margin: 100px; }

View File

@ -0,0 +1,77 @@
@charset "hello-world";
@page :left {
div {
color: red; } }
@page test {
@media yes {
div {
color: red; } } }
@media something {
@page {
@media else {
div {
height: 200px; } } } }
div {
color: red; }
@page yeah {
div pre {
height: 20px; } }
@font-face {
color: red;
height: 20px; }
@keyframes 'bounce' {
from {
top: 100px;
animation-timing-function: ease-out; }
25% {
top: 50px;
animation-timing-function: ease-in; }
50% {
top: 100px;
animation-timing-function: ease-out; }
75% {
top: 75px;
animation-timing-function: ease-in; }
to {
top: 100px; } }
@-webkit-keyframes flowouttoleft {
0% {
-webkit-transform: translateX(0) scale(1); }
60%, 70% {
-webkit-transform: translateX(0) scale(0.7); }
100% {
-webkit-transform: translateX(-100%) scale(0.7); } }
div {
animation-name: 'diagonal-slide';
animation-duration: 5s;
animation-iteration-count: 10; }
@keyframes 'diagonal-slide' {
from {
left: 0;
top: 0; }
to {
left: 100px;
top: 100px; } }
@document url(http://www.w3.org/),
url-prefix(http://www.w3.org/Style/),
domain(mozilla.org),
regexp("https:.*") {
body {
color: purple;
background: yellow; } }

View File

@ -0,0 +1,87 @@
error, pre seriousError, span seriousError, other, hello {
border: 1px #f00;
background-color: #fdd; }
pre seriousError, span seriousError {
font-size: 20px; }
hello {
color: green; }
hello div {
margin: 10px; }
.cool, .me {
color: red; }
.blue, .me {
color: purple; }
a:hover, .hoverlink, #demo .overview .fakelink:hover {
text-decoration: underline; }
div.hello.world.hmm, pre div.okay.span.world.hmm, pre #butt .umm div.sure.span.world.hmm, #butt .umm pre div.sure.span.world.hmm, code div.okay.span.world.hmm, code #butt .umm div.sure.span.world.hmm, #butt .umm code div.sure.span.world.hmm {
color: blue; }
.xxxxx .xxxxx .xxxxx, code .xxxxx .xxxxx, code code .xxxxx, code code code, code .xxxxx code, .xxxxx code .xxxxx, .xxxxx code code, .xxxxx .xxxxx code {
color: green; }
code {
color: red; }
.alpha, .beta, .gama {
color: red; }
.beta, .gama {
color: white; }
.gama {
color: blue; }
#admin .tabbar a, #admin .tabbar #demo .overview .fakelink, #demo .overview #admin .tabbar .fakelink {
font-weight: bold; }
a1 b1 c1 d1, x1 y1 z1 w1 b1 c1 d1 {
color: red; }
a2 b2 c2 d2, a2 x2 y2 z2 w2 c2 d2, x2 y2 z2 a2 w2 c2 d2 {
color: red; }
a3 b3 c3 d3, a3 b3 x3 y3 z3 w3 d3, x3 y3 z3 a3 b3 w3 d3 {
color: red; }
a4 b4 c4 d4, a4 b4 c4 x4 y4 z4 w4, x4 y4 z4 a4 b4 c4 w4 {
color: red; }
#butt .yeah .okay, #butt .yeah .umm .sure, #butt .umm .yeah .sure {
font-weight: bold; }
a9 b9 s9 t9 v9, a9 b9 s9 t9 x9 y9 z9, a9 b9 x9 y9 s9 t9 z9 {
color: red; }
@media print {
horse, man {
color: blue; } }
man {
color: red; }
wassup {
color: blue; }
.foo .wassup {
color: blue; }
#something, .x, .y {
color: red; }
.nav-justified, .nav-tabs.nav-justified {
text-align: justify; }
.btn:hover, .edit .actions button:hover, .edit .new .actions button:hover, .btn:active, .edit .actions button:active, .edit .new .actions button:active, .btn.active, .edit .actions button.active, .edit .new .actions button.active, .btn.disabled, .edit .actions button.disabled, .edit .new .actions button.disabled, .btn[disabled], .edit .actions button[disabled], .edit .new .actions button[disabled] {
color: red; }
.edit .actions button {
float: right; }
.edit .new .actions {
padding: 0; }

View File

@ -0,0 +1,20 @@
#number {
-webkit-filter: grayscale(1) sepia(0.5) saturate(0.1) invert(1) opacity(0.5) brightness(0.5) contrast(0.5); }
#percentage {
-webkit-filter: grayscale(100%) sepia(50%) saturate(10%) invert(100%) opacity(50%) brightness(50%) contrast(50%); }
#misc {
-webkit-filter: hue-rotate(90deg) blur(10px) drop-shadow(10px -16px 30px purple); }
#decimal {
opacity: 0.5;
filter: alpha(opacity=50, style=1); }
#percent {
opacity: 0.5;
filter: alpha(opacity=50); }
.row {
background-color: #071c23;
color: #2284a1; }

View File

@ -0,0 +1,25 @@
div {
color: 14px;
sum: 23; }
div {
hello: 10 55;
hello: 1010 55;
hello: "hello 10 and 55"; }
del {
color: 1000; }
div {
hello: "hello foo and bar";
hello: "hello bar and default";
hello: "hello Alice, Bob, Tom"; }
.foo {
test2: -moz-art; }
div span {
height: 3px; }
div {
width: 2; }

View File

@ -0,0 +1,8 @@
#foo:before {
content: counter(item,".") ": "; }
#bar:before {
content: counter(item,"."); }
#fu:before {
content: counter(item); }

View File

@ -0,0 +1,21 @@
div {
color: blue; }
pre {
val-1: "red";
val-2: "blue";
val-3: "blue";
val-4: "red";
val-5: "red"; }
span {
color: blue;
height: 10px;
width: 20px; }
div {
color: blue;
border-color: green; }
del {
thing: no; }

View File

@ -0,0 +1,2 @@
body {
background-color: "red"; }

View File

@ -0,0 +1,27 @@
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
div {
height: 200px;
color: red; }
pre {
color: red; }
pre div {
height: 200px;
color: red; }
code div {
height: 200px;
color: red; }
code div {
height: 200px;
color: red; }
#partial {
color: blue; }
body {
color: #7c2;
background: gray; }

View File

@ -0,0 +1,54 @@
div {
color: redwhite blue;
color: red white blue;
color: red whiteblue;
color: redwhiteblue;
color: ummyeahwhat;
color: stacked;
font-size: 10px/something;
font-size: 10px / something;
test: "whatworldwrong";
test: "whatworldwrong";
test: "whatworldwrong";
test: "what"world"wrong";
hi: "what is 16 end"; }
pre var {
color: red; }
pre var dad {
color: red; }
pre bedvardad {
color: red; }
cool .thing-1 {
color: red; }
cool .thing-2 {
color: red; }
cool .thing-3 {
color: red; }
cool .thing-4 {
color: red; }
cool .thing-5 {
color: red; }
abcde {
color: red; }
#hello, .world {
color: red; }
#abchelloyeah, .coolworldyes {
color: red; }
div.element:nth-child(2n) {
display: none; }
div {
hello: world;
coolhello: world;
helloone: world;
twohelloone: world;
oneabtwo: cool;
hello-world: red;
hello-mold: white;
hello-hello: blue; }

View File

@ -0,0 +1,6 @@
pre {
out: alpha fort three palace; }
div {
hello: 5;
world: -5; }

View File

@ -0,0 +1,7 @@
div {
padding: 10px 20px 30px 40px;
margin: 0 10px 10px 10px;
background: linear-gradient(black, white); }
p {
background: linear-gradient(red, blue); }

View File

@ -0,0 +1,45 @@
div {
color: what;
color: is;
color: this;
font: what;
font: is;
font: this;
background: what;
background: is;
background: this;
border: what;
border: is;
border: this; }
span {
color: 0;
color: 1;
color: 2;
color: 3;
color: 4;
color: 5;
color: 6;
color: 7;
color: 8;
color: 9;
color: 10; }
pre {
color: 1;
color: 2;
color: 3;
color: 4;
height: 1;
height: 2;
height: 3;
height: 4;
height: 5;
cool: 10;
cool: 9;
cool: 8;
cool: 7;
cool: 6;
cool: 5;
cool: 4;
cool: 3; }

View File

@ -0,0 +1,103 @@
@media {
div {
color: blue; } }
@media what {
div {
color: blue; } }
@media (cool) {
div {
color: blue; } }
@media (cool: blue) {
div {
color: blue; } }
@media hello and (world) and (butt: man) {
div {
color: blue; } }
@media (max-width: 940px) {
color: red; }
@media not hello and (world) {
color: blue;
pre {
color: blue; } }
@media butt and (world) {
color: red;
div {
color: red; } }
div {
color: blue; }
@media screen and (-webkit-min-device-pixel-ratio: 1.5) {
div .sidebar {
width: 500px; } }
div {
position: absolute; }
@media screen {
div {
top: 0;
bottom: 8em;
color: red; }
div p {
margin: 5px; }
div .success {
color: green; } }
.button {
width: 300px;
height: 100px;
background: #eee; }
.button :hover {
background: #aaa; }
@media only screen and (max-width: 300px) {
.button {
width: 100px;
height: 100px; } }
code {
position: absolute; }
@media screen {
code {
height: 10px; }
code pre {
height: 20px; } }
@media screen and (color: blue) {
dt {
height: 10px; } }
@media screen {
.screen {
width: 12px; } }
@media only screen {
.only-screen {
height: 11px; } }
@media only screen {
.only-screen {
width: 14px; } }
@media only screen {
.only-screen {
height: 16px; } }
@media print {
.only-print {
height: 12px; } }
@media screen {
.only-print {
height: 12px; } }
@media not screen {
.not-screen {
height: 15px; } }
@media only screen and (color: blue) and (width: 13) {
.only-screen {
height: 15px; } }

View File

@ -0,0 +1,93 @@
div {
color: blue;
color: red; }
div pre {
height: 200px; }
span {
color: blue; }
span div {
height: 20px; }
html {
height: 43px; }
del {
height: 20px; }
div {
color: white;
color: blue;
color: white; }
div {
background-image: linear-gradient(left top, red, green); }
div {
-moz-box-shadow: 10px 10px 5px #888;
-webkit-box-shadow: 10px 10px 5px #888;
box-shadow: 10px 10px 5px #888;
-moz-box-shadow: inset 10px 10px #888, -10px -10px #f4f4f4;
-webkit-box-shadow: inset 10px 10px #888, -10px -10px #f4f4f4;
box-shadow: inset 10px 10px #888, -10px -10px #f4f4f4; }
div p {
color: red;
color: blue; }
div p .class {
color: red; }
div p .class div {
height: 20px; }
div p div {
height: 20px; }
div p .top {
top: 0; }
div p .top div {
color: red; }
div.mixin-content-simple {
color: red; }
div.mixin-content-with-arg {
background: blue;
color: red; }
div.mixin-content-with-arg {
background: purple;
height: 20px; }
div.mixin-content-simple {
height: 43px; }
div.mixin-content-simple {
color: orange; }
div.mixin-content-simple div {
height: 20px; }
div.mixin-content-with-arg {
background: purple;
height: 43px; }
div.mixin-content-with-arg {
background: purple;
color: orange; }
div.mixin-content-with-arg div {
height: 20px; }
#please-wait {
background: url(/images/logo.png);
position: absolute;
top: 1em;
right: 0;
bottom: 3em;
left: 4em; }
div.parameter-name-scope {
-webkit-transform: translateX(50px); }
@-webkit-keyframes change-color {
0% {
color: green; }
100% {
color: red; } }

View File

@ -0,0 +1,22 @@
div: blue;
body {
color: red; }
div {
color: red;
height: yes; }
div pre {
color: blue; }
div {
font: 10px hello world;
font-size: 10px;
font-color: blue;
border-left: 1px solid blue;
border-right: 2px dashed green; }
#nested-nesting {
bar: baz;
bang-bop: bar;
bang-bip: 1px;
bang-blat-baf: bort; }

View File

@ -0,0 +1,21 @@
.div {
one: null;
one: world;
one: NULL world;
one: a, b;
two: a, b; }
p:before {
content: "I ate pies!"; }
.foo {
-webkit-border-radius: 10;
border-radius: 10; }
.fu {
-webkit-border-radius: 20;
border-radius: 20; }
.bar {
-webkit-border-top-left-radius: 30;
border-top-left-radius: 30; }

View File

@ -0,0 +1,105 @@
body {
color: 8;
color: 16;
height: 10px/10px;
color: 6px;
color: 5px;
bottom: 2px;
top: 1.5em;
left: -1cm;
top: 6.29921; }
div {
color: false;
color: true;
color: true;
color: false;
color: what > 3; }
#units {
test: 2.5748in;
test: 13mm;
test: 4em;
test: 11mm;
test: 1.1cm; }
#modulo {
test: 1;
test: 1cm; }
#colors {
color: #ff0203;
color: #fe0000;
color: rgba(3, 8, 15, 0.5);
color: rgba(5, 8, 10, 0.5);
color: rgba(2, 4, 6, 0.5);
color: rgba(1, 1, 2, 0.5);
color: rgba(3, 4, 5, 0.5);
color: rgba(0, 0, 1, 0.5);
color: #22f;
color: false;
color: true;
color: true;
color: false; }
#preserve {
hello: what -going;
hello: what - going; }
#strings {
hello: what -going;
hello: whatgoing;
hello: whatgoing;
hello: whatgoing;
hello: whatgoing;
hello: "whatgoing";
hello: goingwhat;
hello: "whatwhat"; }
#negation {
a: -60;
b: 10 -100;
b: -90; }
#bools-fail {
and: false and two;
and: one and two;
and: one and false;
or: false or two;
or: one or two;
or: one or false; }
#bools {
and: false;
and: two;
and: false;
or: two;
or: one;
or: one; }
#nots-fail {
not: false2;
not: not false;
not: not 0;
not: not 1;
not: not "";
not: not hello; }
#nots {
not: false2;
not: true;
not: false;
not: false;
not: false;
not: false; }
#string-test {
str: true;
str: false;
str: true;
str: true;
str: xhellohellofalse;
str: true; }
#special {
cancel-unit: 1; }

View File

@ -0,0 +1,50 @@
/* comment 1 */
a {
/* comment 2 */
color: red;
/* comment 3 */
/* comment 4 */ }
/* comment 5 */
/*! comment 1 */
b {
/*! comment 2 */
color: red;
/*! comment 3 */
/*! comment 4 */ }
/*! comment 5 */
/*
* multi-line comment 1
*/
c {
/*
* multi-line comment 2
*/
color: red;
/*
* multi-line comment 3
*/
/*
* multi-line comment 4
*/ }
/*
* multi-line comment 5
*/
/*!
* multi-line comment 1
*/
d {
/*!
* multi-line comment 2
*/
color: red;
/*!
* multi-line comment 3
*/
/*!
* multi-line comment 4
*/ }
/*!
* multi-line comment 5
*/
e {
color: red; }

View File

@ -0,0 +1,7 @@
p a.notice span, p a.error span, #context a.notice span, #context a.error span {
color: blue;
font-weight: bold;
font-size: 2em; }
p {
padding: 2em; }

View File

@ -0,0 +1,771 @@
@import "foo.css";
@import 'foo.css';
@import url("foo.css");
@import url('foo.css');
@import url(foo.css);
@import "foo.css" screen;
@import "foo.css" screen, print;
@charset "UTF-8";
[foo~=bar] {
a: b; }
[foo^=bar] {
a: b; }
[foo$=bar] {
a: b; }
[foo*=bar] {
a: b; }
[foo|=en] {
a: b; }
foo {
a: 2;
b: 2.3em;
c: 50%;
d: "fraz bran";
e: flanny-blanny-blan;
f: url(http://sass-lang.com);
h: #abc; }
selector {
property: value;
property2: value; }
sel {
p: v; }
.foo {
/* Foo
Bar
Baz */
a: b; }
.foo {
/* Foo
Bar
Baz */
a: b; }
.foo {
/* Foo
Bar */
a: b; }
.foo {
/* Foo
Bar
Baz */
a: b; }
@foo {
a: b;
rule {
a: b; } }
@foo {
a: b; }
@bar {
a: b; }
@foo "bar"
foo {
a: 12px calc(100%/3 - 2*1em - 2*1px);
b: 12px -moz-calc(100%/3 - 2*1em - 2*1px);
b: 12px -webkit-calc(100%/3 - 2*1em - 2*1px);
b: 12px -foobar-calc(100%/3 - 2*1em - 2*1px); }
foo {
bar: baz; }
bar {
bar: baz; }
baz {
bar: baz; }
/*
* foo
*/
bar {
baz: bang; }
E, F {
a: b; }
E F, G H {
a: b; }
E > F, G > H {
a: b; }
/* This is a CSS comment. */
.one {
color: green; }
/* Another comment */
/* The following should not be used:
.two {color: red;} */
.three {
color: green;
/* color: red; */ }
/**
.four {color: red;} */
.five {
color: green; }
/**/
.six {
color: green; }
/*********/
.seven {
color: green; }
/* a comment **/
.eight {
color: green; }
foo {
a: \foo bar;
b: foo\ bar;
c: \2022 \0020;
d: foo\\bar;
e: foo\"\'bar; }
foo {
a: "\foo bar";
b: "foo\ bar";
c: "\2022 \0020";
d: "foo\\bar";
e: "foo\"'bar"; }
foo {
_name: val;
*name: val;
:name: val;
.name: val;
#name: val;
name/**/: val;
name/*\**/: val;
name: val; }
@foo "bar" ;
foo {
a: -moz-element(#foo);
b: -webkit-element(#foo);
b: -foobar-element(#foo); }
@foo ;
foo {
bar: baz; }
0% {
a: b; }
60% {
a: b; }
100% {
a: b; }
12px {
a: b; }
"foo" {
a: b; }
foo {
a: 12px expression(1 + (3 / Foo.bar("baz" + "bang") + function() {return 12;}) % 12); }
:foo("bar") {
a: b; }
:foo(bar) {
a: b; }
:foo(12px) {
a: b; }
:foo(+) {
a: b; }
:foo(-) {
a: b; }
:foo(+"bar") {
a: b; }
:foo(-++--baz-"bar"12px) {
a: b; }
foo {
a: foo-bar(12);
b: -foo-bar-baz(13, 14 15); }
@import "foo.css" screen, print and (foo: 0);
@import "foo.css" screen, only print, screen and (foo: 0);
foo {
a: foo !important;
b: foo bar !important;
b: foo, bar !important; }
foo {
a: -moz-bar-baz;
b: foo -o-bar-baz; }
foo {
a: d;
/* b; c: */ }
foo {
a : d;
/*: b; c */ }
/* Foo
* Bar */
.foo {
/* Foo
* Bar */ }
[foo] {
a: b; }
[foo="bar"] {
a: b; }
[foo~="bar"] {
a: b; }
[foo^="bar"] {
a: b; }
[foo$="bar"] {
a: b; }
[foo*="bar"] {
a: b; }
[foo|="en"] {
a: b; }
:root {
a: b; }
:nth-child(n) {
a: b; }
:nth-last-child(n) {
a: b; }
:nth-of-type(n) {
a: b; }
:nth-last-of-type(n) {
a: b; }
:first-child {
a: b; }
:last-child {
a: b; }
:first-of-type {
a: b; }
:last-of-type {
a: b; }
:only-child {
a: b; }
:only-of-type {
a: b; }
:empty {
a: b; }
:link {
a: b; }
:visited {
a: b; }
:active {
a: b; }
:hover {
a: b; }
:focus {
a: b; }
:target {
a: b; }
:lang(fr) {
a: b; }
:enabled {
a: b; }
:disabled {
a: b; }
:checked {
a: b; }
::first-line {
a: b; }
::first-letter {
a: b; }
::before {
a: b; }
::after {
a: b; }
.warning {
a: b; }
#myid {
a: b; }
:not(s) {
a: b; }
@media all {
rule1 {
prop: val; }
rule2 {
prop: val; } }
@media screen, print {
rule1 {
prop: val; }
rule2 {
prop: val; } }
@media screen and (-webkit-min-device-pixel-ratio: 0) {
a: b; }
@media only screen, print and (foo: 0px) and (bar: flam(12px solid)) {
a: b; }
:-moz-any(h1, h2, h3) {
a: b; }
:-moz-any(.foo) {
a: b; }
:-moz-any(foo bar, .baz > .bang) {
a: b; }
@-moz-document url(http://www.w3.org/),
url-prefix(http://www.w3.org/Style/),
domain(mozilla.org),
regexp("^https:.*") {
.foo {
a: b; } }
foo {
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000000);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000000); }
foo {
filter: alpha(opacity=20);
filter: alpha(opacity=20, enabled=true);
filter: blaznicate(foo=bar, baz=bang bip, bart=#fa4600); }
@foo bar {
a: b; }
@bar baz {
c: d; }
@foo bar;
@bar baz;
/* Foo
* Bar */
/* Baz
* Bang */
.foo {
/* Foo
* Bar */
/* Baz
* Bang */ }
.foo {
/* Foo Bar */
/* Baz Bang */ }
@namespace "http://www.w3.org/Profiles/xhtml1-strict";
@namespace url(http://www.w3.org/Profiles/xhtml1-strict);
@namespace html url("http://www.w3.org/Profiles/xhtml1-strict");
[foo|bar=baz] {
a: b; }
[*|bar=baz] {
a: b; }
[foo|bar|=baz] {
a: b; }
foo|E {
a: b; }
*|E {
a: b; }
foo|* {
a: b; }
*|* {
a: b; }
:not(foo|bar) {
a: b; }
:not(*|bar) {
a: b; }
:not(foo|*) {
a: b; }
:not(*|*) {
a: b; }
:not(#blah) {
a: b; }
:not(.blah) {
a: b; }
:not([foo]) {
a: b; }
:not([foo^="bar"]) {
a: b; }
:not([baz|foo~="bar"]) {
a: b; }
:not(:hover) {
a: b; }
:not(:nth-child(2n + 3)) {
a: b; }
:not(:not(#foo)) {
a: b; }
:not(a#foo.bar) {
a: b; }
:not(#foo .bar > baz) {
a: b; }
:not(h1, h2, h3) {
a: b; }
foo {
a: "bang 1 bar bip"; }
:nth-child(-n) {
a: b; }
:nth-child(+n) {
a: b; }
:nth-child(even) {
a: b; }
:nth-child(odd) {
a: b; }
:nth-child(50) {
a: b; }
:nth-child(-50) {
a: b; }
:nth-child(+50) {
a: b; }
:nth-child(2n+3) {
a: b; }
:nth-child(2n-3) {
a: b; }
:nth-child(+2n-3) {
a: b; }
:nth-child(-2n+3) {
a: b; }
:nth-child(-2n+ 3) {
a: b; }
:nth-child( 2n + 3) {
a: b; }
foo {
a: foo bar baz;
b: foo, #abc, -12;
c: 1px/2px/-3px;
d: foo bar, baz/bang; }
@page {
prop1: val;
prop2: val; }
@page flap {
prop1: val;
prop2: val; }
@page :first {
prop1: val;
prop2: val; }
@page flap:first {
prop1: val;
prop2: val; }
.foo {
/* Foo */
a: b; }
.foo {
/* Foo
* Bar */
a: b; }
/* Foo */
.foo {
a: b; }
/* Foo
* Bar */
.foo {
a: b; }
.foo #bar:baz(/* bang )*/ bip) {
/* .a #foo */
a: b; }
> E {
a: b; }
+ E {
a: b; }
~ E {
a: b; }
> > E {
a: b; }
>> E {
a: b; }
E* {
a: b; }
E*.foo {
a: b; }
E*:hover {
a: b; }
E, F {
a: b; }
E F {
a: b; }
E, F G, H {
a: b; }
body {
/*
//comment here
*/ }
E > F {
a: b; }
E ~ F {
a: b; }
E + F {
a: b; }
* {
a: b; }
E {
a: b; }
E[foo] {
a: b; }
E[foo="bar"] {
a: b; }
E[foo~="bar"] {
a: b; }
E[foo^="bar"] {
a: b; }
E[foo$="bar"] {
a: b; }
E[foo*="bar"] {
a: b; }
E[foo|="en"] {
a: b; }
E:root {
a: b; }
E:nth-child(n) {
a: b; }
E:nth-last-child(n) {
a: b; }
E:nth-of-type(n) {
a: b; }
E:nth-last-of-type(n) {
a: b; }
E:first-child {
a: b; }
E:last-child {
a: b; }
E:first-of-type {
a: b; }
E:last-of-type {
a: b; }
E:only-child {
a: b; }
E:only-of-type {
a: b; }
E:empty {
a: b; }
E:link {
a: b; }
E:visited {
a: b; }
E:active {
a: b; }
E:hover {
a: b; }
E:focus {
a: b; }
E:target {
a: b; }
E:lang(fr) {
a: b; }
E:enabled {
a: b; }
E:disabled {
a: b; }
E:checked {
a: b; }
E::first-line {
a: b; }
E::first-letter {
a: b; }
E::before {
a: b; }
E::after {
a: b; }
E.warning {
a: b; }
E#myid {
a: b; }
E:not(s) {
a: b; }
E F {
a: b; }
E > F {
a: b; }
E + F {
a: b; }
E ~ F {
a: b; }
@supports (a: b) and (c: d) or (not (d: e)) and ((not (f: g)) or (not ((h: i) and (j: k)))) {
.foo {
a: b; } }
@-prefix-supports (a: b) and (c: d) or (not (d: e)) and ((not (f: g)) or (not ((h: i) and (j: k)))) {
.foo {
a: b; } }
foo {
foo: bar;
#baz: bang;
#bip: bop; }
foo {
a: -2;
b: -2.3em;
c: -50%;
d: -foo(bar baz); }
foo {
a: -0.5em;
b: 0.5em;
c: -foo(12px);
d: +foo(12px); }
foo {
-moz-foo-bar: blat;
-o-flat-blang: wibble; }
foo {
a: foo();
b: bar baz-bang() bip; }

View File

@ -0,0 +1,341 @@
* {
color: blue; }
E {
color: blue; }
E:not(:link) {
color: blue; }
E:not(:link):not(:visited) {
color: blue; }
E:not(:link, :visited) {
color: blue; }
E:matches(:hover, :focus) {
color: blue; }
E.warning {
color: blue; }
E#id {
color: blue; }
E[foo] {
color: blue; }
E[foo="barbar"] {
color: blue; }
E[foo="barbar" i] {
color: blue; }
E[foo~="hello#$@%@$#^"] {
color: blue; }
E[foo^="color: green;"] {
color: blue; }
E[foo$="239023"] {
color: blue; }
E[foo*="29302"] {
color: blue; }
E[foo|="239032"] {
color: blue; }
[foo] {
color: blue; }
[foo] .helloWorld {
color: blue; }
[foo].helloWorld {
color: blue; }
[foo="barbar"] {
color: blue; }
[foo~="hello#$@%@$#^"] {
color: blue; }
[foo^="color: green;"] {
color: blue; }
[foo$="239023"] {
color: blue; }
[foo*="29302"] {
color: blue; }
[foo|="239032"] {
color: blue; }
E:dir(ltr) {
color: blue; }
E:lang(en) {
color: blue; }
E:lang(en, fr) {
color: blue; }
E:any-link {
color: blue; }
E:link {
color: blue; }
E:visited {
color: blue; }
E:local-link {
color: blue; }
E:local-link(0) {
color: red; }
E:local-link(1) {
color: white; }
E:local-link(2) {
color: red; }
E:target {
color: blue; }
E:scope {
color: blue; }
E:current {
color: blue; }
E:current(:link) {
color: blue; }
E:past {
color: blue; }
E:future {
color: blue; }
E:active {
color: blue; }
E:hover {
color: blue; }
E:focus {
color: blue; }
E:enabled {
color: blue; }
E:disabled {
color: blue; }
E:indeterminate {
color: blue; }
E:default {
color: blue; }
E:in-range {
color: blue; }
E:out-of-range {
color: blue; }
E:required {
color: blue; }
E:optional {
color: blue; }
E:read-only {
color: blue; }
E:read-write {
color: blue; }
E:root {
color: blue; }
E:empty {
color: blue; }
E:first-child {
color: blue; }
E:nth-child(odd) {
color: blue; }
E:nth-child(2n+1) {
color: blue; }
E:nth-child(5) {
color: blue; }
E:last-child {
color: blue; }
E:nth-last-child(-n+2) {
color: blue; }
E:only-child {
color: blue; }
E:first-of-type {
color: blue; }
E:nth-of-type(2n) {
color: blue; }
E:last-of-type {
color: blue; }
E:nth-last-of-type(n) {
color: blue; }
E:only-of-type {
color: blue; }
E:nth-match(odd) {
color: blue; }
E:nth-last-match(odd) {
color: blue; }
E:column(n) {
color: blue; }
E:nth-column(n) {
color: blue; }
E:nth-last-column(n) {
color: blue; }
E F {
color: blue; }
E > F {
color: blue; }
E + F {
color: blue; }
E ~ F {
color: blue; }
E /foo/ F {
color: blue; }
E! > F {
color: blue; }
[foo|att=val] {
color: blue; }
[*|att] {
color: yellow; }
[|att] {
color: green; }
[att] {
color: green; }
E::first-line {
color: blue; }
E::first-letter {
color: blue; }
E::before {
color: blue; }
E::after {
color: blue; }
E::choices {
color: blue; }
E::value {
color: blue; }
E::repeat-index {
color: blue; }
E::repeat-item {
color: blue; }
E:first {
color: blue; }
E:first-line {
color: blue; }
E:first-letter {
color: blue; }
E:before {
color: blue; }
E:after {
color: blue; }
E:checked {
color: blue; }
E:invalid {
color: blue; }
E:valid {
color: blue; }
E:left {
color: blue; }
E:right {
color: blue; }
E:any(ol) {
color: blue; }
E::selection {
color: blue; }
div {
font: something;
font-size: 30em; }
div font:something {
size: 30em; }
.something.world {
color: blue; }
.something .mold {
height: 200px; }
.dog .something {
color: blue; }
.dad .simple .wolf {
color: blue; }
.rad.simple.bad {
color: blue; }
.something div .what.world {
color: blue; }
div.foo div {
color: blue; }
.nice-fonts .main .message div .title, .nice-fonts div .message div .title {
font-size: 24px; }
.escape\% {
color: red; }
.escape-plan\% {
color: green; }

View File

@ -0,0 +1,34 @@
#values {
color: #eee;
color: #eee;
height: 20px;
width: 80%;
color: "hello world";
height: url("http://google.com");
dads: url(http://leafo.net);
padding: 10px 10px 10px 10px, 3px 3px 3px;
textblock: "This is a \
multiline block \
#not { color: #eee;}";
margin: 4, 3, 1;
content: "This is a \
multiline string.";
border-radius: -1px -1px -1px black; }
#subtraction {
lit: 10 -11;
lit: -1;
lit: -1;
lit: -1;
var: 10 -100;
var: -90;
var: -90;
var: -90; }
#special {
a: 12px expression(1 + (3 / Foo.bar("baz" + "bang") + function() {return 12;}) % 12); }
#unary {
b: 0.5em;
c: -foo(12px);
d: +foo(12px); }

View File

@ -0,0 +1,24 @@
cool: 100px;
div {
height: red, two, three; }
div {
num: 1000; }
div {
num: 2000; }
pre {
color: blue; }
del {
color: red; }
del div pre {
color: red; }
body {
font-family: Arial;
font-family: Helvetica Neue;
font-family: "Helvetica Neue";
font-family: Helvetica, Arial, sans-serif;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }

View File

@ -0,0 +1,47 @@
* change all calls to reduce to not suppress division where appropriate
* store count in elements so we can have position of compile time errors
* failed parsing paths can add comments early
* fix indentation for @content, see @content tests
misc:
# sequence merging:
a b c d { color: red; }
x y z w { @extend a; }
a b c d, x y z w b c d { color: red; }
a b c d { color: red; }
x y z w { @extend b; }
a b c d, a x y z w c d, x y z a w c d { color: red; }
a b c d { color: red; }
x y z w { @extend c; }
a b c d, a b x y z w d, x y z a b w d { color: red; }
x y z a b w d
before: a b
after: d
new: x y z w
a b c d { color: red; }
x y z w { @extend d; }
a b c d, a b c x y z w, x y z a b c w { color: red; }
->> new[:-1] . before . new[-1] . after
new.len > 1
before not empty

View File

@ -0,0 +1,724 @@
* 1.18.0 (2015-XX-XX)
* fixed some error messages where the line was wrong (unknown variables or argument names)
* added a new way to customize the main Module node (via empty nodes)
* added Twig_Environment::createTemplate() to create a template from a string
* added a profiler
* fixed filesystem loader cache when different file paths are used for the same template
* 1.17.0 (2015-01-14)
* added a 'filename' autoescaping strategy, which dynamically chooses the
autoescaping strategy for a template based on template file extension.
* 1.16.3 (2014-12-25)
* fixed regression for dynamic parent templates
* fixed cache management with statcache
* fixed a regression in the slice filter
* 1.16.2 (2014-10-17)
* fixed timezone on dates as strings
* fixed 2-words test names when a custom node class is not used
* fixed macros when using an argument named like a PHP super global (like GET or POST)
* fixed date_modify when working with DateTimeImmutable
* optimized for loops
* fixed multi-byte characters handling in the split filter
* fixed a regression in the in operator
* fixed a regression in the slice filter
* 1.16.1 (2014-10-10)
* improved error reporting in a sandboxed template
* fixed missing error file/line information under certain circumstances
* fixed wrong error line number in some error messages
* fixed the in operator to use strict comparisons
* sped up the slice filter
* fixed for mb function overload mb_substr acting different
* fixed the attribute() function when passing a variable for the arguments
* 1.16.0 (2014-07-05)
* changed url_encode to always encode according to RFC 3986
* fixed inheritance in a 'use'-hierarchy
* removed the __toString policy check when the sandbox is disabled
* fixed recursively calling blocks in templates with inheritance
* 1.15.1 (2014-02-13)
* fixed the conversion of the special '0000-00-00 00:00' date
* added an error message when trying to import an undefined block from a trait
* fixed a C extension crash when accessing defined but uninitialized property.
* 1.15.0 (2013-12-06)
* made ignoreStrictCheck in Template::getAttribute() works with __call() methods throwing BadMethodCallException
* added min and max functions
* added the round filter
* fixed a bug that prevented the optimizers to be enabled/disabled selectively
* fixed first and last filters for UTF-8 strings
* added a source function to include the content of a template without rendering it
* fixed the C extension sandbox behavior when get or set is prepend to method name
* 1.14.2 (2013-10-30)
* fixed error filename/line when an error occurs in an included file
* allowed operators that contain whitespaces to have more than one whitespace
* allowed tests to be made of 1 or 2 words (like "same as" or "divisible by")
* 1.14.1 (2013-10-15)
* made it possible to use named operators as variables
* fixed the possibility to have a variable named 'matches'
* added support for PHP 5.5 DateTimeInterface
* 1.14.0 (2013-10-03)
* fixed usage of the html_attr escaping strategy to avoid double-escaping with the html strategy
* added new operators: ends with, starts with, and matches
* fixed some compatibility issues with HHVM
* added a way to add custom escaping strategies
* fixed the C extension compilation on Windows
* fixed the batch filter when using a fill argument with an exact match of elements to batch
* fixed the filesystem loader cache when a template name exists in several namespaces
* fixed template_from_string when the template includes or extends other ones
* fixed a crash of the C extension on an edge case
* 1.13.2 (2013-08-03)
* fixed the error line number for an error occurs in and embedded template
* fixed crashes of the C extension on some edge cases
* 1.13.1 (2013-06-06)
* added the possibility to ignore the filesystem constructor argument in Twig_Loader_Filesystem
* fixed Twig_Loader_Chain::exists() for a loader which implements Twig_ExistsLoaderInterface
* adjusted backtrace call to reduce memory usage when an error occurs
* added support for object instances as the second argument of the constant test
* fixed the include function when used in an assignment
* 1.13.0 (2013-05-10)
* fixed getting a numeric-like item on a variable ('09' for instance)
* fixed getting a boolean or float key on an array, so it is consistent with PHP's array access:
`{{ array[false] }}` behaves the same as `echo $array[false];` (equals `$array[0]`)
* made the escape filter 20% faster for happy path (escaping string for html with UTF-8)
* changed ☃ to § in tests
* enforced usage of named arguments after positional ones
* 1.12.3 (2013-04-08)
* fixed a security issue in the filesystem loader where it was possible to include a template one
level above the configured path
* fixed fatal error that should be an exception when adding a filter/function/test too late
* added a batch filter
* added support for encoding an array as query string in the url_encode filter
* 1.12.2 (2013-02-09)
* fixed the timezone used by the date filter and function when the given date contains a timezone (like 2010-01-28T15:00:00+02:00)
* fixed globals when getGlobals is called early on
* added the first and last filter
* 1.12.1 (2013-01-15)
* added support for object instances as the second argument of the constant function
* relaxed globals management to avoid a BC break
* added support for {{ some_string[:2] }}
* 1.12.0 (2013-01-08)
* added verbatim as an alias for the raw tag to avoid confusion with the raw filter
* fixed registration of tests and functions as anonymous functions
* fixed globals management
* 1.12.0-RC1 (2012-12-29)
* added an include function (does the same as the include tag but in a more flexible way)
* added the ability to use any PHP callable to define filters, functions, and tests
* added a syntax error when using a loop variable that is not defined
* added the ability to set default values for macro arguments
* added support for named arguments for filters, tests, and functions
* moved filters/functions/tests syntax errors to the parser
* added support for extended ternary operator syntaxes
* 1.11.1 (2012-11-11)
* fixed debug info line numbering (was off by 2)
* fixed escaping when calling a macro inside another one (regression introduced in 1.9.1)
* optimized variable access on PHP 5.4
* fixed a crash of the C extension when an exception was thrown from a macro called without being imported (using _self.XXX)
* 1.11.0 (2012-11-07)
* fixed macro compilation when a variable name is a PHP reserved keyword
* changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone
* fixed bitwise operator precedences
* added the template_from_string function
* fixed default timezone usage for the date function
* optimized the way Twig exceptions are managed (to make them faster)
* added Twig_ExistsLoaderInterface (implementing this interface in your loader make the chain loader much faster)
* 1.10.3 (2012-10-19)
* fixed wrong template location in some error messages
* reverted a BC break introduced in 1.10.2
* added a split filter
* 1.10.2 (2012-10-15)
* fixed macro calls on PHP 5.4
* 1.10.1 (2012-10-15)
* made a speed optimization to macro calls when imported via the "import" tag
* fixed C extension compilation on Windows
* fixed a segfault in the C extension when using DateTime objects
* 1.10.0 (2012-09-28)
* extracted functional tests framework to make it reusable for third-party extensions
* added namespaced templates support in Twig_Loader_Filesystem
* added Twig_Loader_Filesystem::prependPath()
* fixed an error when a token parser pass a closure as a test to the subparse() method
* 1.9.2 (2012-08-25)
* fixed the in operator for objects that contain circular references
* fixed the C extension when accessing a public property of an object implementing the \ArrayAccess interface
* 1.9.1 (2012-07-22)
* optimized macro calls when auto-escaping is on
* fixed wrong parent class for Twig_Function_Node
* made Twig_Loader_Chain more explicit about problems
* 1.9.0 (2012-07-13)
* made the parsing independent of the template loaders
* fixed exception trace when an error occurs when rendering a child template
* added escaping strategies for CSS, URL, and HTML attributes
* fixed nested embed tag calls
* added the date_modify filter
* 1.8.3 (2012-06-17)
* fixed paths in the filesystem loader when passing a path that ends with a slash or a backslash
* fixed escaping when a project defines a function named html or js
* fixed chmod mode to apply the umask correctly
* 1.8.2 (2012-05-30)
* added the abs filter
* fixed a regression when using a number in template attributes
* fixed compiler when mbstring.func_overload is set to 2
* fixed DateTimeZone support in date filter
* 1.8.1 (2012-05-17)
* fixed a regression when dealing with SimpleXMLElement instances in templates
* fixed "is_safe" value for the "dump" function when "html_errors" is not defined in php.ini
* switched to use mbstring whenever possible instead of iconv (you might need to update your encoding as mbstring and iconv encoding names sometimes differ)
* 1.8.0 (2012-05-08)
* enforced interface when adding tests, filters, functions, and node visitors from extensions
* fixed a side-effect of the date filter where the timezone might be changed
* simplified usage of the autoescape tag; the only (optional) argument is now the escaping strategy or false (with a BC layer)
* added a way to dynamically change the auto-escaping strategy according to the template "filename"
* changed the autoescape option to also accept a supported escaping strategy (for BC, true is equivalent to html)
* added an embed tag
* 1.7.0 (2012-04-24)
* fixed a PHP warning when using CIFS
* fixed template line number in some exceptions
* added an iterable test
* added an error when defining two blocks with the same name in a template
* added the preserves_safety option for filters
* fixed a PHP notice when trying to access a key on a non-object/array variable
* enhanced error reporting when the template file is an instance of SplFileInfo
* added Twig_Environment::mergeGlobals()
* added compilation checks to avoid misuses of the sandbox tag
* fixed filesystem loader freshness logic for high traffic websites
* fixed random function when charset is null
* 1.6.5 (2012-04-11)
* fixed a regression when a template only extends another one without defining any blocks
* 1.6.4 (2012-04-02)
* fixed PHP notice in Twig_Error::guessTemplateLine() introduced in 1.6.3
* fixed performance when compiling large files
* optimized parent template creation when the template does not use dynamic inheritance
* 1.6.3 (2012-03-22)
* fixed usage of Z_ADDREF_P for PHP 5.2 in the C extension
* fixed compilation of numeric values used in templates when using a locale where the decimal separator is not a dot
* made the strategy used to guess the real template file name and line number in exception messages much faster and more accurate
* 1.6.2 (2012-03-18)
* fixed sandbox mode when used with inheritance
* added preserveKeys support for the slice filter
* fixed the date filter when a DateTime instance is passed with a specific timezone
* added a trim filter
* 1.6.1 (2012-02-29)
* fixed Twig C extension
* removed the creation of Twig_Markup instances when not needed
* added a way to set the default global timezone for dates
* fixed the slice filter on strings when the length is not specified
* fixed the creation of the cache directory in case of a race condition
* 1.6.0 (2012-02-04)
* fixed raw blocks when used with the whitespace trim option
* made a speed optimization to macro calls when imported via the "from" tag
* fixed globals, parsers, visitors, filters, tests, and functions management in Twig_Environment when a new one or new extension is added
* fixed the attribute function when passing arguments
* added slice notation support for the [] operator (syntactic sugar for the slice operator)
* added a slice filter
* added string support for the reverse filter
* fixed the empty test and the length filter for Twig_Markup instances
* added a date function to ease date comparison
* fixed unary operators precedence
* added recursive parsing support in the parser
* added string and integer handling for the random function
* 1.5.1 (2012-01-05)
* fixed a regression when parsing strings
* 1.5.0 (2012-01-04)
* added Traversable objects support for the join filter
* 1.5.0-RC2 (2011-12-30)
* added a way to set the default global date interval format
* fixed the date filter for DateInterval instances (setTimezone() does not exist for them)
* refactored Twig_Template::display() to ease its extension
* added a number_format filter
* 1.5.0-RC1 (2011-12-26)
* removed the need to quote hash keys
* allowed hash keys to be any expression
* added a do tag
* added a flush tag
* added support for dynamically named filters and functions
* added a dump function to help debugging templates
* added a nl2br filter
* added a random function
* added a way to change the default format for the date filter
* fixed the lexer when an operator ending with a letter ends a line
* added string interpolation support
* enhanced exceptions for unknown filters, functions, tests, and tags
* 1.4.0 (2011-12-07)
* fixed lexer when using big numbers (> PHP_INT_MAX)
* added missing preserveKeys argument to the reverse filter
* fixed macros containing filter tag calls
* 1.4.0-RC2 (2011-11-27)
* removed usage of Reflection in Twig_Template::getAttribute()
* added a C extension that can optionally replace Twig_Template::getAttribute()
* added negative timestamp support to the date filter
* 1.4.0-RC1 (2011-11-20)
* optimized variable access when using PHP 5.4
* changed the precedence of the .. operator to be more consistent with languages that implements such a feature like Ruby
* added an Exception to Twig_Loader_Array::isFresh() method when the template does not exist to be consistent with other loaders
* added Twig_Function_Node to allow more complex functions to have their own Node class
* added Twig_Filter_Node to allow more complex filters to have their own Node class
* added Twig_Test_Node to allow more complex tests to have their own Node class
* added a better error message when a template is empty but contain a BOM
* fixed "in" operator for empty strings
* fixed the "defined" test and the "default" filter (now works with more than one call (foo.bar.foo) and for both values of the strict_variables option)
* changed the way extensions are loaded (addFilter/addFunction/addGlobal/addTest/addNodeVisitor/addTokenParser/addExtension can now be called in any order)
* added Twig_Environment::display()
* made the escape filter smarter when the encoding is not supported by PHP
* added a convert_encoding filter
* moved all node manipulations outside the compile() Node method
* made several speed optimizations
* 1.3.0 (2011-10-08)
no changes
* 1.3.0-RC1 (2011-10-04)
* added an optimization for the parent() function
* added cache reloading when auto_reload is true and an extension has been modified
* added the possibility to force the escaping of a string already marked as safe (instance of Twig_Markup)
* allowed empty templates to be used as traits
* added traits support for the "parent" function
* 1.2.0 (2011-09-13)
no changes
* 1.2.0-RC1 (2011-09-10)
* enhanced the exception when a tag remains unclosed
* added support for empty Countable objects for the "empty" test
* fixed algorithm that determines if a template using inheritance is valid (no output between block definitions)
* added better support for encoding problems when escaping a string (available as of PHP 5.4)
* added a way to ignore a missing template when using the "include" tag ({% include "foo" ignore missing %})
* added support for an array of templates to the "include" and "extends" tags ({% include ['foo', 'bar'] %})
* added support for bitwise operators in expressions
* added the "attribute" function to allow getting dynamic attributes on variables
* added Twig_Loader_Chain
* added Twig_Loader_Array::setTemplate()
* added an optimization for the set tag when used to capture a large chunk of static text
* changed name regex to match PHP one "[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*" (works for blocks, tags, functions, filters, and macros)
* removed the possibility to use the "extends" tag from a block
* added "if" modifier support to "for" loops
* 1.1.2 (2011-07-30)
* fixed json_encode filter on PHP 5.2
* fixed regression introduced in 1.1.1 ({{ block(foo|lower) }})
* fixed inheritance when using conditional parents
* fixed compilation of templates when the body of a child template is not empty
* fixed output when a macro throws an exception
* fixed a parsing problem when a large chunk of text is enclosed in a comment tag
* added PHPDoc for all Token parsers and Core extension functions
* 1.1.1 (2011-07-17)
* added a performance optimization in the Optimizer (also helps to lower the number of nested level calls)
* made some performance improvement for some edge cases
* 1.1.0 (2011-06-28)
* fixed json_encode filter
* 1.1.0-RC3 (2011-06-24)
* fixed method case-sensitivity when using the sandbox mode
* added timezone support for the date filter
* fixed possible security problems with NUL bytes
* 1.1.0-RC2 (2011-06-16)
* added an exception when the template passed to "use" is not a string
* made 'a.b is defined' not throw an exception if a is not defined (in strict mode)
* added {% line \d+ %} directive
* 1.1.0-RC1 (2011-05-28)
Flush your cache after upgrading.
* fixed date filter when using a timestamp
* fixed the defined test for some cases
* fixed a parsing problem when a large chunk of text is enclosed in a raw tag
* added support for horizontal reuse of template blocks (see docs for more information)
* added whitespace control modifier to all tags (see docs for more information)
* added null as an alias for none (the null test is also an alias for the none test now)
* made TRUE, FALSE, NONE equivalent to their lowercase counterparts
* wrapped all compilation and runtime exceptions with Twig_Error_Runtime and added logic to guess the template name and line
* moved display() method to Twig_Template (generated templates should now use doDisplay() instead)
* 1.0.0 (2011-03-27)
* fixed output when using mbstring
* fixed duplicate call of methods when using the sandbox
* made the charset configurable for the escape filter
* 1.0.0-RC2 (2011-02-21)
* changed the way {% set %} works when capturing (the content is now marked as safe)
* added support for macro name in the endmacro tag
* make Twig_Error compatible with PHP 5.3.0 >
* fixed an infinite loop on some Windows configurations
* fixed the "length" filter for numbers
* fixed Template::getAttribute() as properties in PHP are case sensitive
* removed coupling between Twig_Node and Twig_Template
* fixed the ternary operator precedence rule
* 1.0.0-RC1 (2011-01-09)
Backward incompatibilities:
* the "items" filter, which has been deprecated for quite a long time now, has been removed
* the "range" filter has been converted to a function: 0|range(10) -> range(0, 10)
* the "constant" filter has been converted to a function: {{ some_date|date('DATE_W3C'|constant) }} -> {{ some_date|date(constant('DATE_W3C')) }}
* the "cycle" filter has been converted to a function: {{ ['odd', 'even']|cycle(i) }} -> {{ cycle(['odd', 'even'], i) }}
* the "for" tag does not support "joined by" anymore
* the "autoescape" first argument is now "true"/"false" (instead of "on"/"off")
* the "parent" tag has been replaced by a "parent" function ({{ parent() }} instead of {% parent %})
* the "display" tag has been replaced by a "block" function ({{ block('title') }} instead of {% display title %})
* removed the grammar and simple token parser (moved to the Twig Extensions repository)
Changes:
* added "needs_context" option for filters and functions (the context is then passed as a first argument)
* added global variables support
* made macros return their value instead of echoing directly (fixes calling a macro in sandbox mode)
* added the "from" tag to import macros as functions
* added support for functions (a function is just syntactic sugar for a getAttribute() call)
* made macros callable when sandbox mode is enabled
* added an exception when a macro uses a reserved name
* the "default" filter now uses the "empty" test instead of just checking for null
* added the "empty" test
* 0.9.10 (2010-12-16)
Backward incompatibilities:
* The Escaper extension is enabled by default, which means that all displayed
variables are now automatically escaped. You can revert to the previous
behavior by removing the extension via $env->removeExtension('escaper')
or just set the 'autoescape' option to 'false'.
* removed the "without loop" attribute for the "for" tag (not needed anymore
as the Optimizer take care of that for most cases)
* arrays and hashes have now a different syntax
* arrays keep the same syntax with square brackets: [1, 2]
* hashes now use curly braces (["a": "b"] should now be written as {"a": "b"})
* support for "arrays with keys" and "hashes without keys" is not supported anymore ([1, "foo": "bar"] or {"foo": "bar", 1})
* the i18n extension is now part of the Twig Extensions repository
Changes:
* added the merge filter
* removed 'is_escaper' option for filters (a left over from the previous version) -- you must use 'is_safe' now instead
* fixed usage of operators as method names (like is, in, and not)
* changed the order of execution for node visitors
* fixed default() filter behavior when used with strict_variables set to on
* fixed filesystem loader compatibility with PHAR files
* enhanced error messages when an unexpected token is parsed in an expression
* fixed filename not being added to syntax error messages
* added the autoescape option to enable/disable autoescaping
* removed the newline after a comment (mimics PHP behavior)
* added a syntax error exception when parent block is used on a template that does not extend another one
* made the Escaper extension enabled by default
* fixed sandbox extension when used with auto output escaping
* fixed escaper when wrapping a Twig_Node_Print (the original class must be preserved)
* added an Optimizer extension (enabled by default; optimizes "for" loops and "raw" filters)
* added priority to node visitors
* 0.9.9 (2010-11-28)
Backward incompatibilities:
* the self special variable has been renamed to _self
* the odd and even filters are now tests:
{{ foo|odd }} must now be written {{ foo is odd }}
* the "safe" filter has been renamed to "raw"
* in Node classes,
sub-nodes are now accessed via getNode() (instead of property access)
attributes via getAttribute() (instead of array access)
* the urlencode filter had been renamed to url_encode
* the include tag now merges the passed variables with the current context by default
(the old behavior is still possible by adding the "only" keyword)
* moved Exceptions to Twig_Error_* (Twig_SyntaxError/Twig_RuntimeError are now Twig_Error_Syntax/Twig_Error_Runtime)
* removed support for {{ 1 < i < 3 }} (use {{ i > 1 and i < 3 }} instead)
* the "in" filter has been removed ({{ a|in(b) }} should now be written {{ a in b }})
Changes:
* added file and line to Twig_Error_Runtime exceptions thrown from Twig_Template
* changed trans tag to accept any variable for the plural count
* fixed sandbox mode (__toString() method check was not enforced if called implicitly from complex statements)
* added the ** (power) operator
* changed the algorithm used for parsing expressions
* added the spaceless tag
* removed trim_blocks option
* added support for is*() methods for attributes (foo.bar now looks for foo->getBar() or foo->isBar())
* changed all exceptions to extend Twig_Error
* fixed unary expressions ({{ not(1 or 0) }})
* fixed child templates (with an extend tag) that uses one or more imports
* added support for {{ 1 not in [2, 3] }} (more readable than the current {{ not (1 in [2, 3]) }})
* escaping has been rewritten
* the implementation of template inheritance has been rewritten
(blocks can now be called individually and still work with inheritance)
* fixed error handling for if tag when a syntax error occurs within a subparse process
* added a way to implement custom logic for resolving token parsers given a tag name
* fixed js escaper to be stricter (now uses a whilelist-based js escaper)
* added the following filers: "constant", "trans", "replace", "json_encode"
* added a "constant" test
* fixed objects with __toString() not being autoescaped
* fixed subscript expressions when calling __call() (methods now keep the case)
* added "test" feature (accessible via the "is" operator)
* removed the debug tag (should be done in an extension)
* fixed trans tag when no vars are used in plural form
* fixed race condition when writing template cache
* added the special _charset variable to reference the current charset
* added the special _context variable to reference the current context
* renamed self to _self (to avoid conflict)
* fixed Twig_Template::getAttribute() for protected properties
* 0.9.8 (2010-06-28)
Backward incompatibilities:
* the trans tag plural count is now attached to the plural tag:
old: `{% trans count %}...{% plural %}...{% endtrans %}`
new: `{% trans %}...{% plural count %}...{% endtrans %}`
* added a way to translate strings coming from a variable ({% trans var %})
* fixed trans tag when used with the Escaper extension
* fixed default cache umask
* removed Twig_Template instances from the debug tag output
* fixed objects with __isset() defined
* fixed set tag when used with a capture
* fixed type hinting for Twig_Environment::addFilter() method
* 0.9.7 (2010-06-12)
Backward incompatibilities:
* changed 'as' to '=' for the set tag ({% set title as "Title" %} must now be {% set title = "Title" %})
* removed the sandboxed attribute of the include tag (use the new sandbox tag instead)
* refactored the Node system (if you have custom nodes, you will have to update them to use the new API)
* added self as a special variable that refers to the current template (useful for importing macros from the current template)
* added Twig_Template instance support to the include tag
* added support for dynamic and conditional inheritance ({% extends some_var %} and {% extends standalone ? "minimum" : "base" %})
* added a grammar sub-framework to ease the creation of custom tags
* fixed the for tag for large arrays (some loop variables are now only available for arrays and objects that implement the Countable interface)
* removed the Twig_Resource::resolveMissingFilter() method
* fixed the filter tag which did not apply filtering to included files
* added a bunch of unit tests
* added a bunch of phpdoc
* added a sandbox tag in the sandbox extension
* changed the date filter to support any date format supported by DateTime
* added strict_variable setting to throw an exception when an invalid variable is used in a template (disabled by default)
* added the lexer, parser, and compiler as arguments to the Twig_Environment constructor
* changed the cache option to only accepts an explicit path to a cache directory or false
* added a way to add token parsers, filters, and visitors without creating an extension
* added three interfaces: Twig_NodeInterface, Twig_TokenParserInterface, and Twig_FilterInterface
* changed the generated code to match the new coding standards
* fixed sandbox mode (__toString() method check was not enforced if called implicitly from a simple statement like {{ article }})
* added an exception when a child template has a non-empty body (as it is always ignored when rendering)
* 0.9.6 (2010-05-12)
* fixed variables defined outside a loop and for which the value changes in a for loop
* fixed the test suite for PHP 5.2 and older versions of PHPUnit
* added support for __call() in expression resolution
* fixed node visiting for macros (macros are now visited by visitors as any other node)
* fixed nested block definitions with a parent call (rarely useful but nonetheless supported now)
* added the cycle filter
* fixed the Lexer when mbstring.func_overload is used with an mbstring.internal_encoding different from ASCII
* added a long-syntax for the set tag ({% set foo %}...{% endset %})
* unit tests are now powered by PHPUnit
* added support for gettext via the `i18n` extension
* fixed twig_capitalize_string_filter() and fixed twig_length_filter() when used with UTF-8 values
* added a more useful exception if an if tag is not closed properly
* added support for escaping strategy in the autoescape tag
* fixed lexer when a template has a big chunk of text between/in a block
* 0.9.5 (2010-01-20)
As for any new release, don't forget to remove all cached templates after
upgrading.
If you have defined custom filters, you MUST upgrade them for this release. To
upgrade, replace "array" with "new Twig_Filter_Function", and replace the
environment constant by the "needs_environment" option:
// before
'even' => array('twig_is_even_filter', false),
'escape' => array('twig_escape_filter', true),
// after
'even' => new Twig_Filter_Function('twig_is_even_filter'),
'escape' => new Twig_Filter_Function('twig_escape_filter', array('needs_environment' => true)),
If you have created NodeTransformer classes, you will need to upgrade them to
the new interface (please note that the interface is not yet considered
stable).
* fixed list nodes that did not extend the Twig_NodeListInterface
* added the "without loop" option to the for tag (it disables the generation of the loop variable)
* refactored node transformers to node visitors
* fixed automatic-escaping for blocks
* added a way to specify variables to pass to an included template
* changed the automatic-escaping rules to be more sensible and more configurable in custom filters (the documentation lists all the rules)
* improved the filter system to allow object methods to be used as filters
* changed the Array and String loaders to actually make use of the cache mechanism
* included the default filter function definitions in the extension class files directly (Core, Escaper)
* added the // operator (like the floor() PHP function)
* added the .. operator (as a syntactic sugar for the range filter when the step is 1)
* added the in operator (as a syntactic sugar for the in filter)
* added the following filters in the Core extension: in, range
* added support for arrays (same behavior as in PHP, a mix between lists and dictionaries, arrays and hashes)
* enhanced some error messages to provide better feedback in case of parsing errors
* 0.9.4 (2009-12-02)
If you have custom loaders, you MUST upgrade them for this release: The
Twig_Loader base class has been removed, and the Twig_LoaderInterface has also
been changed (see the source code for more information or the documentation).
* added support for DateTime instances for the date filter
* fixed loop.last when the array only has one item
* made it possible to insert newlines in tag and variable blocks
* fixed a bug when a literal '\n' were present in a template text
* fixed bug when the filename of a template contains */
* refactored loaders
* 0.9.3 (2009-11-11)
This release is NOT backward compatible with the previous releases.
The loaders do not take the cache and autoReload arguments anymore. Instead,
the Twig_Environment class has two new options: cache and auto_reload.
Upgrading your code means changing this kind of code:
$loader = new Twig_Loader_Filesystem('/path/to/templates', '/path/to/compilation_cache', true);
$twig = new Twig_Environment($loader);
to something like this:
$loader = new Twig_Loader_Filesystem('/path/to/templates');
$twig = new Twig_Environment($loader, array(
'cache' => '/path/to/compilation_cache',
'auto_reload' => true,
));
* deprecated the "items" filter as it is not needed anymore
* made cache and auto_reload options of Twig_Environment instead of arguments of Twig_Loader
* optimized template loading speed
* removed output when an error occurs in a template and render() is used
* made major speed improvements for loops (up to 300% on even the smallest loops)
* added properties as part of the sandbox mode
* added public properties support (obj.item can now be the item property on the obj object)
* extended set tag to support expression as value ({% set foo as 'foo' ~ 'bar' %} )
* fixed bug when \ was used in HTML
* 0.9.2 (2009-10-29)
* made some speed optimizations
* changed the cache extension to .php
* added a js escaping strategy
* added support for short block tag
* changed the filter tag to allow chained filters
* made lexer more flexible as you can now change the default delimiters
* added set tag
* changed default directory permission when cache dir does not exist (more secure)
* added macro support
* changed filters first optional argument to be a Twig_Environment instance instead of a Twig_Template instance
* made Twig_Autoloader::autoload() a static method
* avoid writing template file if an error occurs
* added $ escaping when outputting raw strings
* enhanced some error messages to ease debugging
* fixed empty cache files when the template contains an error
* 0.9.1 (2009-10-14)
* fixed a bug in PHP 5.2.6
* fixed numbers with one than one decimal
* added support for method calls with arguments ({{ foo.bar('a', 43) }})
* made small speed optimizations
* made minor tweaks to allow better extensibility and flexibility
* 0.9.0 (2009-10-12)
* Initial release

Some files were not shown because too many files have changed in this diff Show More