Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resolved issues #34 and #35

  • Loading branch information...
commit 9cd0981d2e6c911795f46a15316fccc247b646cc 1 parent 83542a3
@peteboere authored
View
6 CHANGELOG.txt
@@ -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)
View
2  CssCrush.php
@@ -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
View
2  composer.json
@@ -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": [
{
View
37 lib/Core.php
@@ -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
@@ -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 );
@@ -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;
}
@@ -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(
@@ -702,6 +713,7 @@ 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 ) {
@@ -709,8 +721,10 @@ protected static function compile ( $stream ) {
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
@@ -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;
}
View
2  lib/Function.php
@@ -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',
View
6 lib/Importer.php
@@ -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
View
1  lib/Regex.php
@@ -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';
}
Please sign in to comment.
Something went wrong with that request. Please try again.