Skip to content

Commit

Permalink
Resolved issues #34 and #35
Browse files Browse the repository at this point in the history
  • Loading branch information
peteboere committed Aug 22, 2012
1 parent 83542a3 commit 9cd0981
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.6.1
---
Resolved issue #35
Resolved issue #34


1.6
---
Inheritance model improved to support adoption of pseudo classes and elements (see wiki)
Expand Down
2 changes: 1 addition & 1 deletion CssCrush.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* CSS Crush
* Extensible CSS preprocessor
*
* @version 1.6
* @version 1.6.1
* @link https://github.com/peteboere/css-crush
* @license http://www.opensource.org/licenses/mit-license.php (MIT)
* @copyright (c) 2010-2012 Pete Boere
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"description": "CSS preprocessor",
"keywords": ["css", "preprocessor"],
"homepage": "http://github.com/peteboere/css-crush",
"homepage": "http://the-echoplex.net/csscrush",
"license": "MIT",
"authors": [
{
Expand Down
37 changes: 28 additions & 9 deletions lib/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ protected static function loadAssets () {

// Load aliases file if it exists
if ( $aliases_file ) {

if ( $result = @parse_ini_file( $aliases_file, true ) ) {

self::$config->aliasesRaw = $result;

// Value aliases require a little preprocessing
Expand All @@ -130,6 +132,14 @@ protected static function loadAssets () {
}
self::$config->aliasesRaw[ 'values' ] = $store;
}

// Ensure all alias groups are at least set (issue #34)
self::$config->aliasesRaw += array(
'properties' => array(),
'functions' => array(),
'values' => array(),
'at-rules' => array(),
);
}
else {
trigger_error( __METHOD__ . ": Aliases file could not be parsed.\n", E_USER_NOTICE );
Expand Down Expand Up @@ -568,14 +578,14 @@ protected static function pruneAliases () {
// If a vendor target is given, we prune the aliases array
$vendor = self::$options[ 'vendor_target' ];

// For expicit 'none' argument turn off aliases
if ( 'none' === $vendor ) {
self::$config->aliases = null;
// Default vendor argument, use all aliases as normal
if ( 'all' === $vendor ) {
return;
}

// Default vendor argument, use all aliases as normal
if ( 'all' === $vendor ) {
// For expicit 'none' argument turn off aliases
if ( 'none' === $vendor ) {
self::$config->aliases = null;
return;
}

Expand Down Expand Up @@ -682,6 +692,7 @@ protected static function reset ( $options = null ) {
self::$process->abstracts = array();
self::$process->errors = array();
self::$process->selectorRelationships = array();
self::$process->charset = null;

self::$storage = (object) array();
self::$storage->tokens = (object) array(
Expand All @@ -702,15 +713,18 @@ protected static function reset ( $options = null ) {
protected static function compile ( $stream ) {

$options = self::$options;
$process = self::$process;

// Load in aliases and macros
if ( ! self::$assetsLoaded ) {
self::loadAssets();
self::$assetsLoaded = true;
}

// Set aliases. May be pruned if a vendor target is set
// Set aliases
self::$config->aliases = self::$config->aliasesRaw;

// Prune if a vendor target is set
self::pruneAliases();

// Parse variables
Expand Down Expand Up @@ -759,11 +773,16 @@ protected static function compile ( $stream ) {
$stream = self::getBoilerplate() . "\n$stream";
}

// Add @charset at top if set
if ( $process->charset ) {
$stream = "@charset \"{$process->charset}\";\n" . $stream;
}

// Release memory
self::$storage = null;
self::$process->mixins = null;
self::$process->abstracts = null;
self::$process->selectorRelationships = null;
$process->mixins = null;
$process->abstracts = null;
$process->selectorRelationships = null;

return $stream;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Function.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static function css_fn__data_uri ( $input ) {

// Only allow certain extensions
$allowed_file_extensions = array(
'woff' => 'font/woff;charset=utf-8',
'woff' => 'application/x-font-woff;charset=utf-8',
'ttf' => 'font/truetype;charset=utf-8',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
Expand Down
6 changes: 6 additions & 0 deletions lib/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public static function hostfile () {
$stream = file_get_contents( $prependFile ) . $stream;
}

// If @charset is set store it
if ( preg_match( $regex->charset, $stream, $m ) ) {
$stream = preg_replace( $regex->charset, '', $stream );
$process->charset = $m[2];
}

csscrush::prepareStream( $stream );

// If rewriting URLs as absolute we need to do some extra work
Expand Down
1 change: 1 addition & 0 deletions lib/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static function init () {
$patt->absoluteUrl = '!^https?://!';
$patt->argListSplit = '!\s*[,\s]\s*!S';
$patt->mathBlacklist = '![^\.0-9\*\/\+\-\(\)]!S';
$patt->charset = '!@charset\s+([\'"])([\w-]+)\1\s*;!i';
}


Expand Down

0 comments on commit 9cd0981

Please sign in to comment.