Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Commit

Permalink
Fixed parser on missing semicolon in the last property
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jan 7, 2013
1 parent 5f9a1e6 commit 4434562
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Stylecow/Parser.php
Expand Up @@ -8,7 +8,7 @@
*
* @author Oscar Otero <http://oscarotero.com> <oom@oscarotero.com>
* @license GNU Affero GPL version 3. http://www.gnu.org/licenses/agpl-3.0.html
* @version 1.0.0 (2012)
* @version 1.0.1 (2013)
*/

namespace Stylecow;
Expand All @@ -25,19 +25,19 @@ class Parser {
*
* @param string $file The path to file to load
*
* @return Stylecow\Css The css object with the code parsed
* @return Stylecow\Css The css object with the code parsed or false if file doesn't exist
*/
static public function parseFile ($file) {
self::$basePath = (strpos($file, '/') === false) ? '' : dirname($file);
self::$baseUrl = '';
self::$basePath = self::$baseUrl = null;

if (is_file($file)) {
$css = self::parseString(file_get_contents($file));
if (!is_file($file)) {
return false;
}

self::$basePath = self::$baseUrl = null;
self::$basePath = (strpos($file, '/') === false) ? '' : dirname($file);
self::$baseUrl = '';

return $css;
return self::parseString(file_get_contents($file));
}


Expand Down Expand Up @@ -184,7 +184,12 @@ static private function parse ($string_code) {

$Child = $Css->addChild(new Css(Selector::createFromString($selector)));

$string_piece = ($n === 0) ? '' : trim(substr($string_code, 0, $n-1));
$string_piece = ($n === 0) ? '' : trim(substr($string_code, 0, $n));

if (substr($string_piece, -1) === ';') {
$string_piece = substr($string_piece, 0, -1);
}

$string_code = trim(substr($string_code, $n+1));
$pos = strpos($string_piece, '{');

Expand Down Expand Up @@ -407,4 +412,4 @@ static public function executeFunctions ($string, $function, $callback, $argumen
return $string;
}
}
?>
?>

0 comments on commit 4434562

Please sign in to comment.