Code Monkey home page Code Monkey logo

iless's People

Contributors

cvrebert avatar hason avatar mishal avatar tleilax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

iless's Issues

Cache does not work with source map output

The parser with file cache enabled and source map output options does not work.

PHP Fatal error:  Call to a member function getPath() on null in /%PATH%/vendor/mishal/iless/lib/ILess/Output/MappedOutput.php on line 82

tests bootstrap.php doesn't work as written

The tests/ILess/boostrap.php file in v2.0.3 seems to have wrong/missing code in order to test...seems like it should be more like

require dirname(__FILE__) . '/ILess/Test/TestCase.php';
require dirname(__FILE__) . '/../lib/ILess/Autoloader.php';

define('ILESS_TEST_CACHE_DIR', sys_get_temp_dir().'/iless-test');

if (is_dir(ILESS_TEST_CACHE_DIR)) {
    // clear the directory
    $files = glob(ILESS_TEST_CACHE_DIR.'/*');
    foreach ($files as $file) {
        if (is_file($file)) {
            unlink($file);
        }
    }
    rmdir(ILESS_TEST_CACHE_DIR);
}

ILess\Autoloader::register();

InvalidArgumentException when set custom variable with value "transparent"

when using custom varible like this:
$parser->setVariables(array('mycolor'=>'transparent'));

lib throws:
EXCEPTION: InvalidArgumentException: [0]: Argument must be a color keyword or 3/6 digit hex e.g. #FFF

problem is that ILess_Variable detect value "transparent" as color but it can not create ILess_Color('transparent')

Using PSR-2

Most of the PHP word is formatting their language using PSR-2. Especially the indenting in this library violates their format: the use of 2 spaces instead of 4. Any motivation behind that?

I believe contributing would be easier if a standard way of formatting was used.

Q: How to determine "early" whether $parser->getCSS() was satisfied from cache?

I want to use ILess with caching in the following manner:

  • the application passes a .less file path and requests the URL of a compiled stylesheet that can be served statically, e.g.:

<link rel="stylesheet" type="text/css" href="<?=compiled_stylesheet_url('style.less')?>"/>

  • the framework (which I am writing) decides where the generated .css should be, ensures it is there by compiling the .less file and writing the .css file if necessary, and returns URI to the .css.

Is it possible to determine that $parser->getCSS() was satisfied completely from cache without loading the compiled file and comparing its contents with the output of $parser->getCSS()? And ideally, is it possible to determine that everything is up to date before even calling $parser->getCSS()?

Travis build fails for php 5.2

$ git clone --depth=50 --branch=develop git://github.com/mishal/iless.git mishal/iless
Cloning into 'mishal/iless'...
remote: Counting objects: 1008, done.
remote: Compressing objects: 100% (615/615), done.
remote: Total 1008 (delta 343), reused 815 (delta 228)
Receiving objects: 100% (1008/1008), 481.50 KiB | 0 bytes/s, done.
Resolving deltas: 100% (343/343), done.
Checking connectivity... done.
$ cd mishal/iless
$ git checkout -qf 5f35d20e349a955c82a12b9e64d63b87b20d150f
0.03s$ phpenv global 5.2
rbenv: version `5.2' not installed
The command "phpenv global 5.2" failed and exited with 1 during .

Spaces removed from calc property

.elem {
  width: calc(~'100% + @{grid-gutter-width}');
}

Expected Result:

.elem {
  width: calc(100% + 10px);
}

Result:

.elem {
  width: calc(100%+10px);
}

Unfortunately Chrome doesn't understand the expression if there are no spaces.

Using `fade` produces error

The following code

body {
    color: fade(#ffcc00, 10%);
}

Will produce the following error against current master

Notice: Array to string conversion in mishal/iless/lib/ILess/Node/Anonymous.php on line 56
Call Stack
#   Time    Memory  Function    Location
10  0.0683  6295224 ILess_Parser_Core->getCSS( )    ../LessRendererDecorator.php:91
11  0.0683  6295928 ILess_Parser->toCSS( )  ../Core.php:321
12  0.0683  6296312 ILess_Parser_Core->toCSS( ) ../Parser.php:72
13  0.0688  6323600 ILess_Node_Ruleset->compile( )  ../Core.php:358
14  0.0688  6325008 ILess_Node_Ruleset->compile( )  ../Ruleset.php:269
15  0.0689  6327600 ILess_Node_Rule->compile( ) ../Ruleset.php:269
16  0.0689  6328104 ILess_Node_Value->compile( )    ../Rule.php:125
17  0.0689  6328600 ILess_Node_Expression->compile( )   ../Value.php:59
18  0.0689  6329064 ILess_Node_Call->compile( ) ../Expression.php:103
19  0.0689  6329680 ILess_FunctionRegistry->call( ) ../Call.php:93
20  0.0689  6330200 call_user_func_array ( )    ../FunctionRegistry.php:292
21  0.0689  6330752 ILess_FunctionRegistry->fade( ) ../FunctionRegistry.php:292
22  0.0690  6330808 ILess_Node_Color->toHSL( )  ../FunctionRegistry.php:1260
23  0.0690  6338848 ILess_Node_Anonymous->__construct( )    ../Color.php:216

Math setup fails on locale with comma as decimal point

The bcmath module uses strings for input and in the cases these are implicitly converted from floats the locale effects the results. For example: M_PI -> "3,141592..." which bcmath then fails to parse and returns 0. This causes a divion by zero in Math setup.

Either saving/changing/restoring the locale or explicit float conversion could fix this.

detached rulesets aren't imported when using reference option

Normal less variables import as expected, but detached rulesets don't import. For example

@import ( reference ) "_detached-rulesets-test.less"
@_my_detached_ruleset();
.test_normal_variables {
    margin: unit( @_normal_variable_test, px );
}

and in _detached-rulesets-test.less

@_normal_variable_test: 26;
@_my_detached_ruleset: {
    BODY {
        margin: 10px;
    }
}

this gives the output

.test_normal_variables {
    margin: 26px;
}

setVariables doesn't handle rgba values right

When passing a Variable like array('a' => 'rgb(46, 120, 176)'), he doen't convert it correctly. The darken() method throws an error when using this variable for darkening.

object(ILess_Node_Anonymous)#1022 (6) { ["type":protected]=> string(9) "Anonymous" ["index"]=> int(0) ["mapLines"]=> bool(false) ["value"]=> string(17) "rgb(46, 120, 176)" ["debugInfo"]=> NULL ["currentFileInfo"]=> NULL }

Error evaluating functiondarken: Cannot darken the color. Invalid color given. in [input string] on line: 2, column: 24 1: 2: #mxtest { color: darken(@a, 20); background: -moz-linear-gradient(top, @a 0%, darken(@a, 20) 100%); /* FF3.6+ */} 3:

parser fails with error code for long data uri

Using URLs with very long data uri i.e. for an embedded font-face, causes php to exit with an error code during parsing:
for example:

@font-face { font-family: 'Glyphicons Halflings'; src:url(data:font/opentype;base64,n04AAEFNAA...<snip 26,000 characters>...gKA9IEaYJg); }

A PHPUnit test will abort with the message:

Process finished with exit code -1073741571 (0xC00000FD)

This might also be the cause of #38

Namespaces

May I ask why the no use is made of PHP's namespaces? Is that related to the way this library is ported? Could be good reasons for it: so just curious!

Is there any test for 'no changes' to compilation?

Based on the docs/examples, we'd ALWAYS have to get the css and then write it out, but that's not the best use of a cache...e.g., if we're running the compiler for every less sheet on our page and then have to write out every css file on each page load, that's a lot of time wasted.

In both lessphp & less.php the cachedCompile() method returns a compiled date so you can determine if the cache/output was updated. I don't see anything like that being set or availble with the $parser->cache.

clean() dangerous

In FileSystem.php, clean() deletes all files in cache dir. Example sets cache dir as system cache dir. It should at least do a file extension check.

I don't think you use clean() currently, but I suggest to fix or remove.

Caching not well documented

For those of us wanting to replace lessphp with iless, we must understand how to replace our auto-compile/caching code. Caching is referred to in one sample, but not well documented.

Parser->toCSS() crashes on empty variable?

When attempting to compile and passing an empty variable (@Swatch: "") the compiler will hard crash with no error message (Core.php line #447) during Parser->toCss(). @Swatch is used to determine the folder name for the 'swatch' which empty would indicate the one in the root folder. This works correctly under iLess v1.7.0.

Error when compiling bootstrap3 with strict_math option enabled

When I try to compile bootstrap3 with strict_math option turned on, the parser ends up in an endless loop.

Fatal error: Maximum function nesting level of '199' reached, aborting! in lib\ILess\Node\Operation.php on line 85

This is a problem also in less.js which exists with:

FATAL ERROR: JS Allocation failed - process out of memory.

The issue is described here: less/less.js#1725

In general: how is this library ported/maintained?

I would love to get some insight in how you created this library @mishal. Would you like to elaborate on the following:

  • How close is this implementation to the reference JS LESS version?
  • What makes this library more maintable than the LESSPHP version?
  • Did you make use of a parser generator?

The two most frustating points in LESSPHP are that it is no longer being maintained (PR's from over 7 months) and that the output differs on some places from the JS reference implementation. If these points are tackled by this repo then chances are that people are going to switch.

Use other (build in) functions from custom function

How can one use functions already build in to the library from a custom function?

The following code shows an example of what I am trying to accomplish.

$parser->addFunction('foo', function() {
    return $this->rgb(0, 0, 0);
});

A solution would be to pass the function registry as a first parameter into the custom function. The second and n'th parameter are then the parameters actually inputted.

Fix unit tests when bcmath is off

Fix unit tests when bcmath is off

There are issues:

There were 16 failures:
1) ILess_Test_Issues_031Test::testIssue
The math setup works
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
    -    'rad' => '0.1591549430918953'
        -    'deg' => '0.0027777777777777'
-    'grad' => '0.0025000000000000'
+    'rad' => '0.15915494309189'
+    'deg' => '0.0027777777777778'
+    'grad' => '0.0025'
     'turn' => '1'
 )
/home/travis/build/mishal/iless/tests/ILess/Test/Issues/031Test.php:49
2) ILess_Test_MathTest::testRound with data set #0 ('1.499999', 0, '1')
Rounding of "1.499999" with precision "0" works
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1'
+'1.999999'
/home/travis/build/mishal/iless/tests/ILess/Test/MathTest.php:44
3) ILess_Test_MathTest::testRound with data set #1 ('71.52', 0, '72')
Rounding of "71.52" with precision "0" works
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'72'
+'72.02'
/home/travis/build/mishal/iless/tests/ILess/Test/MathTest.php:44
4) ILess_Test_MathTest::testRound with data set #2 ('78.47', 0, '78')
Rounding of "78.47" with precision "0" works
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'78'
+'78.97'
/home/travis/build/mishal/iless/tests/ILess/Test/MathTest.php:44
5) ILess_Test_MathTest::testRound with data set #3 ('71.25', 0, '71')
Rounding of "71.25" with precision "0" works
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'71'
+'71.75'
/home/travis/build/mishal/iless/tests/ILess/Test/MathTest.php:44
6) ILess_Test_Node_ColorTest::testGetSaturation
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'88%'
+'88.119047619048%'
/home/travis/build/mishal/iless/tests/ILess/Test/Node/ColorTest.php:104
7) ILess_Test_Node_ColorTest::testGetLightness
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'59%'
+'59.323529411765%'
/home/travis/build/mishal/iless/tests/ILess/Test/Node/ColorTest.php:114
8) ILess_Test_Node_ColorTest::testGetHue
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'283'
+'283.54347826087'
/home/travis/build/mishal/iless/tests/ILess/Test/Node/ColorTest.php:124
9) ILess_Test_Parser_ParsingTest::testCompilation with data set #3 ('/home/travis/build/mishal/ile...s.less', '/home/travis/build/mishal/ile...ns.css')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
'body {
-  luma-green: 72%;
-  luma-cyan: 79%;
+  luma-green: 72.02%;
+  luma-cyan: 79.24%;
   hue: 98;
   lightness: 95%;
-  saturation: 88%;
+  saturation: 88.119047619048%;
 }
 '
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:77
10) ILess_Test_Parser_ParsingTest::testCompilation with data set #4 ('/home/travis/build/mishal/ile...l.less', '/home/travis/build/mishal/ile...sl.css')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
'body {
   red: 191.25;
   green: 63.75;
-  blue: 106.2499999999999;
+  blue: 106.25;
   lightness: 50%;
   color: #bf406a;
 }
 '
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:77
11) ILess_Test_Parser_ParsingTest::testCompilation with data set #10 ('/home/travis/build/mishal/ile...s.less', '/home/travis/build/mishal/ile...rs.css')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
    #alpha #hsla {
-  color: rgba(61, 45, 41, 0.6);
+  color: rgba(61.7, 45.04, 41.3, 0.6);
 }
 #overflow .a {
   color: #000000;
 }
 #overflow .b {
   color: #ffffff;
 }
 #overflow .c {
   color: #ffffff;
 }
 #overflow .d {
   color: #00ff00;
 }
 #grey {
   color: #c8c8c8;
 }
 #333333 {
   color: #333333;
 }
 #808080 {
   color: #808080;
 }
 #00ff00 {
   color: #00ff00;
 }
 .lightenblue {
    color: #3333ff;
}
 .darkenblue {
    color: #0000cc;
}
 .unknowncolors {
    color: blue2;
    border: 2px solid superred;
 }
 .transparent {
    color: transparent;
    background-color: rgba(0, 0, 0, 0);
 }
 #alpha #fromvar {
   opacity: 0.7;
 }
 #alpha #short {
   opacity: 1;
 }
 #alpha #long {
   opacity: 1;
 }
 #alpha #rgba {
   opacity: 0.2;
 }
 #alpha #hsl {
   opacity: 1;
 }
 #percentage {
   color: 255;
   border-color: rgba(255, 0, 0, 0.5);
 }
 '
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:77
12) ILess_Test_Parser_ParsingTest::testCompilation with data set #24 ('/home/travis/build/mishal/ile...s.less', '/home/travis/build/mishal/ile...ns.css')
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    21 => '  luma-red: 21.76%;'
-    22 => '  luma-green: 72.02%;'
-    23 => '  luma-blue: 7.72%;'
-    24 => '  luma-yellow: 93.28%;'
-    25 => '  luma-cyan: 79.24%;'
-    26 => '  luma-white-alpha: 50.5%;'
-    63 => '  rounded: 11.166666666667;'
-    64 => '  rounded-two: 10.671666666667;'
-    65 => '  roundedpx: 3.8333333333333px;'
-    66 => '  roundedpx-three: 3.3338333333333px;'
-    67 => '  rounded-percentage: 10.7%;'
-    69 => '  floor: 12.9px;'
-    71 => '  pi: 3.1415926535898;'
-    74 => '  tan: 0.9004040442979;'
-    75 => '  sin: 0.17364817766694;'
-    76 => '  cos: 0.84385395873249;'
-    77 => '  atan: 0.099999999999999rad;'
-    78 => '  atan: 34deg;'
-    79 => '  atan: 44.999999999998deg;'
-    97 => '  fade-in: rgba(255, 0, 0, 0.95);'
-    99 => '  hsva: rgba(77, 40.6625, 38.75, 0.2);'
 )
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:75
13) ILess_Test_Parser_ParsingTest::testCompilation with data set #46 ('/home/travis/build/mishal/ile...s.less', '/home/travis/build/mishal/ile...ns.css')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
   border-radius-keep: 5px;
-  border-radius-parts: 1.1428571428571428px;
+  border-radius-parts: 1.1428571428571px;
   border-radius-all: 5px;
 }
 .negative {
   neg-var: -1;
   neg-var-paren: -1;
 }
 .nested-parens {
   width: 71;
   height: 6;
 }
 .mixed-units {
   margin: 2px 4em 1 5pc;
   padding: 6px 1em 2px 2;
 }
 '
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:77
14) ILess_Test_Parser_ParsingTest::testCompilation with data set #52 ('/home/travis/build/mishal/ile...s.less', '/home/travis/build/mishal/ile...es.css')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
conversion-metric-b: 3cm;
-  conversion-imperial: 2.999999999999557in;
+  conversion-imperial: 3in;
   custom-unit: 420octocats;
   custom-unit-cancelling: 18dogs;
   mix-units: 2px;
   invalid-units: 1px;
 }
 '
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:77
15) ILess_Test_Parser_ParsingTest::testCompilation with data set #55 ('/home/travis/build/mishal/ile...p.less', '/home/travis/build/mishal/ile...ap.css')
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    354 => '  margin-left: 2.1276595744681%;'
-    355 => '  *margin-left: 2.0744680851064%;'
-    361 => '  margin-left: 2.1276595744681%;'
-    365 => '  *width: 99.946808510638%;'
-    368 => '  width: 91.489361702128%;'
-    369 => '  *width: 91.436170212766%;'
-    372 => '  width: 82.978723404256%;'
-    373 => '  *width: 82.925531914894%;'
-    376 => '  width: 74.468085106384%;'
-    377 => '  *width: 74.414893617022%;'
-    380 => '  width: 65.957446808511%;'
-    381 => '  *width: 65.904255319149%;'
-    384 => '  width: 57.446808510639%;'
-    385 => '  *width: 57.393617021277%;'
-    388 => '  width: 48.936170212767%;'
-    389 => '  *width: 48.882978723405%;'
-    392 => '  width: 40.425531914893%;'
-    393 => '  *width: 40.372340425531%;'
-    396 => '  width: 31.914893617021%;'
-    397 => '  *width: 31.861702127659%;'
-    400 => '  width: 23.404255319149%;'
-    401 => '  *width: 23.351063829787%;'
-    404 => '  width: 14.893617021277%;'
-    405 => '  *width: 14.840425531915%;'
-    408 => '  width: 6.3829787234043%;'
-    409 => '  *width: 6.3297872340426%;'
-    412 => '  margin-left: 104.25531914894%;'
-    413 => '  *margin-left: 104.14893617021%;'
-    416 => '  margin-left: 102.12765957447%;'
-    417 => '  *margin-left: 102.02127659575%;'
-    420 => '  margin-left: 95.744680851064%;'
-    421 => '  *margin-left: 95.63829787234%;'
-    424 => '  margin-left: 93.617021276596%;'
-    425 => '  *margin-left: 93.510638297872%;'
-    428 => '  margin-left: 87.234042553192%;'
-    429 => '  *margin-left: 87.127659574468%;'
-    432 => '  margin-left: 85.106382978724%;'
-    433 => '  *margin-left: 85%;'
-    436 => '  margin-left: 78.72340425532%;'
-    437 => '  *margin-left: 78.617021276596%;'
-    440 => '  margin-left: 76.595744680852%;'
-    441 => '  *margin-left: 76.489361702128%;'
-    444 => '  margin-left: 70.212765957447%;'
-    445 => '  *margin-left: 70.106382978723%;'
-    448 => '  margin-left: 68.085106382979%;'
-    449 => '  *margin-left: 67.978723404255%;'
-    452 => '  margin-left: 61.702127659575%;'
-    453 => '  *margin-left: 61.595744680851%;'
-    456 => '  margin-left: 59.574468085107%;'
-    457 => '  *margin-left: 59.468085106383%;'
-    460 => '  margin-left: 53.191489361703%;'
-    461 => '  *margin-left: 53.085106382979%;'
-    464 => '  margin-left: 51.063829787235%;'
-    465 => '  *margin-left: 50.957446808511%;'
-    468 => '  margin-left: 44.680851063829%;'
-    469 => '  *margin-left: 44.574468085105%;'
-    472 => '  margin-left: 42.553191489361%;'
-    473 => '  *margin-left: 42.446808510637%;'
-    476 => '  margin-left: 36.170212765957%;'
-    477 => '  *margin-left: 36.063829787233%;'
-    480 => '  margin-left: 34.042553191489%;'
-    481 => '  *margin-left: 33.936170212765%;'
-    484 => '  margin-left: 27.659574468085%;'
-    485 => '  *margin-left: 27.553191489361%;'
-    488 => '  margin-left: 25.531914893617%;'
-    489 => '  *margin-left: 25.425531914893%;'
-    492 => '  margin-left: 19.148936170213%;'
-    493 => '  *margin-left: 19.042553191489%;'
-    496 => '  margin-left: 17.021276595745%;'
-    497 => '  *margin-left: 16.914893617021%;'
-    500 => '  margin-left: 10.63829787234%;'
-    501 => '  *margin-left: 10.531914893617%;'
-    504 => '  margin-left: 8.5106382978724%;'
-    505 => '  *margin-left: 8.404255319149%;'
-    2827 => '  border-color: #0044cc #0044...02b80;'
-    2841 => '  *background-color: #003cb3;'
-    3000 => '  background-color: #090909 \9;'
 )
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:75
16) ILess_Test_Parser_ParsingTest::testCompilation with data set #56 ('/home/travis/build/mishal/ile...p.less', '/home/travis/build/mishal/ile...ap.css', array(true))
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
    -    325 => '  margin-top: 20.000000006px;'
        -    326 => '  margin-bottom: 20.000000006px;'
-    391 => '  margin-top: 20.000000006px;'
-    392 => '  margin-bottom: 10.000000003px;'
-    414 => '  margin-top: 10.000000003px;'
-    415 => '  margin-bottom: 10.000000003px;'
-    433 => '  font-size: 36.4px;'
-    437 => '  font-size: 30.1px;'
-    456 => '  margin: 0 0 10.000000003px;'
-    459 => '  margin-bottom: 20.000000006px;'
-    460 => '  font-size: 16.1px;'
-    553 => '  padding-bottom: 9.000000003px;'
-    554 => '  margin: 40.000000012px 0 20...006px;'
-    560 => '  margin-bottom: 10.000000003px;'
-    586 => '  margin-bottom: 20.000000006px;'
-    622 => '  padding: 10.000000003px 20....006px;'
-    623 => '  margin: 0 0 20.000000006px;'
-    674 => '  margin-bottom: 20.000000006px;'
-    702 => '  padding: 9.500000003px;'
-    703 => '  margin: 0 0 10.000000003px;'
-    769 => '  width: 91.666666666667%;'
-    772 => '  width: 83.333333333333%;'
-    778 => '  width: 66.666666666667%;'
-    781 => '  width: 58.333333333333%;'
-    787 => '  width: 41.666666666667%;'
-    790 => '  width: 33.333333333333%;'
-    796 => '  width: 16.666666666667%;'
-    799 => '  width: 8.3333333333333%;'
-    805 => '  right: 91.666666666667%;'
-    808 => '  right: 83.333333333333%;'
-    814 => '  right: 66.666666666667%;'
-    817 => '  right: 58.333333333333%;'
-    823 => '  right: 41.666666666667%;'
-    826 => '  right: 33.333333333333%;'
-    832 => '  right: 16.666666666667%;'
-    835 => '  right: 8.3333333333333%;'
-    844 => '  left: 91.666666666667%;'
-    847 => '  left: 83.333333333333%;'
-    853 => '  left: 66.666666666667%;'
-    856 => '  left: 58.333333333333%;'
-    862 => '  left: 41.666666666667%;'
-    865 => '  left: 33.333333333333%;'
-    871 => '  left: 16.666666666667%;'
-    874 => '  left: 8.3333333333333%;'
-    883 => '  margin-left: 91.666666666667%;'
-    886 => '  margin-left: 83.333333333333%;'
-    892 => '  margin-left: 66.666666666667%;'
-    895 => '  margin-left: 58.333333333333%;'
-    901 => '  margin-left: 41.666666666667%;'
-    904 => '  margin-left: 33.333333333333%;'
-    910 => '  margin-left: 16.666666666667%;'
-    913 => '  margin-left: 8.3333333333333%;'
-    926 => '    width: 91.666666666667%;'
-    929 => '    width: 83.333333333333%;'
-    935 => '    width: 66.666666666667%;'
-    938 => '    width: 58.333333333333%;'
-    944 => '    width: 41.666666666667%;'
-    947 => '    width: 33.333333333333%;'
-    953 => '    width: 16.666666666667%;'
-    956 => '    width: 8.3333333333333%;'
-    962 => '    right: 91.666666666667%;'
-    965 => '    right: 83.333333333333%;'
-    971 => '    right: 66.666666666667%;'
-    974 => '    right: 58.333333333333%;'
-    980 => '    right: 41.666666666667%;'
-    983 => '    right: 33.333333333333%;'
-    989 => '    right: 16.666666666667%;'
-    992 => '    right: 8.3333333333333%;'
-    1001 => '    left: 91.666666666667%;'
-    1004 => '    left: 83.333333333333%;'
-    1010 => '    left: 66.666666666667%;'
-    1013 => '    left: 58.333333333333%;'
-    1019 => '    left: 41.666666666667%;'
-    1022 => '    left: 33.333333333333%;'
-    1028 => '    left: 16.666666666667%;'
-    1031 => '    left: 8.3333333333333%;'
-    1040 => '    margin-left: 91.666666666667%;'
-    1043 => '    margin-left: 83.333333333333%;'
-    1049 => '    margin-left: 66.666666666667%;'
-    1052 => '    margin-left: 58.333333333333%;'
-    1058 => '    margin-left: 41.666666666667%;'
-    1061 => '    margin-left: 33.333333333333%;'
-    1067 => '    margin-left: 16.666666666667%;'
-    1070 => '    margin-left: 8.3333333333333%;'
-    1084 => '    width: 91.666666666667%;'
-    1087 => '    width: 83.333333333333%;'
-    1093 => '    width: 66.666666666667%;'
-    1096 => '    width: 58.333333333333%;'
-    1102 => '    width: 41.666666666667%;'
-    1105 => '    width: 33.333333333333%;'
-    1111 => '    width: 16.666666666667%;'
-    1114 => '    width: 8.3333333333333%;'
-    1120 => '    right: 91.666666666667%;'
-    1123 => '    right: 83.333333333333%;'
-    1129 => '    right: 66.666666666667%;'
-    1132 => '    right: 58.333333333333%;'
-    1138 => '    right: 41.666666666667%;'
-    1141 => '    right: 33.333333333333%;'
-    1147 => '    right: 16.666666666667%;'
-    1150 => '    right: 8.3333333333333%;'
-    1159 => '    left: 91.666666666667%;'
-    1162 => '    left: 83.333333333333%;'
-    1168 => '    left: 66.666666666667%;'
-    1171 => '    left: 58.333333333333%;'
-    1177 => '    left: 41.666666666667%;'
-    1180 => '    left: 33.333333333333%;'
-    1186 => '    left: 16.666666666667%;'
-    1189 => '    left: 8.3333333333333%;'
-    1198 => '    margin-left: 91.666666666667%;'
-    1201 => '    margin-left: 83.333333333333%;'
-    1207 => '    margin-left: 66.666666666667%;'
-    1210 => '    margin-left: 58.333333333333%;'
-    1216 => '    margin-left: 41.666666666667%;'
-    1219 => '    margin-left: 33.333333333333%;'
-    1225 => '    margin-left: 16.666666666667%;'
-    1228 => '    margin-left: 8.3333333333333%;'
-    1242 => '    width: 91.666666666667%;'
-    1245 => '    width: 83.333333333333%;'
-    1251 => '    width: 66.666666666667%;'
-    1254 => '    width: 58.333333333333%;'
-    1260 => '    width: 41.666666666667%;'
-    1263 => '    width: 33.333333333333%;'
-    1269 => '    width: 16.666666666667%;'
-    1272 => '    width: 8.3333333333333%;'
-    1278 => '    right: 91.666666666667%;'
-    1281 => '    right: 83.333333333333%;'
-    1287 => '    right: 66.666666666667%;'
-    1290 => '    right: 58.333333333333%;'
-    1296 => '    right: 41.666666666667%;'
-    1299 => '    right: 33.333333333333%;'
-    1305 => '    right: 16.666666666667%;'
-    1308 => '    right: 8.3333333333333%;'
-    1317 => '    left: 91.666666666667%;'
-    1320 => '    left: 83.333333333333%;'
-    1326 => '    left: 66.666666666667%;'
-    1329 => '    left: 58.333333333333%;'
-    1335 => '    left: 41.666666666667%;'
-    1338 => '    left: 33.333333333333%;'
-    1344 => '    left: 16.666666666667%;'
-    1347 => '    left: 8.3333333333333%;'
-    1356 => '    margin-left: 91.666666666667%;'
-    1359 => '    margin-left: 83.333333333333%;'
-    1365 => '    margin-left: 66.666666666667%;'
-    1368 => '    margin-left: 58.333333333333%;'
-    1374 => '    margin-left: 41.666666666667%;'
-    1377 => '    margin-left: 33.333333333333%;'
-    1383 => '    margin-left: 16.666666666667%;'
-    1386 => '    margin-left: 8.3333333333333%;'
-    1401 => '  margin-bottom: 20.000000006px;'
-    1577 => '    margin-bottom: 15.0000000045px;'
-    1631 => '  margin-bottom: 20.000000006px;'
-    1683 => '  height: 34.000000006px;'
-    1727 => '  line-height: 34.000000006px;'
-    1735 => '  min-height: 20.000000006px;'
-    1819 => '  padding-right: 42.5000000075px;'
-    1823 => '  top: 25.000000006px;'
-    1826 => '  width: 34.000000006px;'
-    1827 => '  height: 34.000000006px;'
-    1828 => '  line-height: 34.000000006px;'
-    1961 => '  min-height: 27.000000006px;'
-    3016 => '  margin: 9.000000003px 0;'
-    3483 => '  margin: 9.000000003px 0;'
-    3641 => '  margin-bottom: 20.000000006px;'
-    3737 => '  padding: 14.999999997px 15px;'
-    3739 => '  line-height: 20.000000006px;'
-    3740 => '  height: 20.000000006px;'
-    3782 => '  margin: 7.4999999985px -15px;'
-    3787 => '  line-height: 20.000000006px;'
-    3804 => '    line-height: 20.000000006px;'
-    3820 => '    padding-top: 14.999999997px;'
-    3821 => '    padding-bottom: 14.999999997px;'
-    3843 => '  margin-top: 7.999999997px;'
-    3844 => '  margin-bottom: 7.999999997px;'
-    3908 => '  margin-top: 7.999999997px;'
-    3909 => '  margin-bottom: 7.999999997px;'
-    3920 => '  margin-top: 14.999999997px;'
-    3921 => '  margin-bottom: 14.999999997px;'
-    4018 => '  border-color: #090909;'
-    4043 => '  background-color: #090909;'
-    4068 => '  background-color: #090909;'
-    4073 => '    border-color: #090909;'
-    4076 => '    background-color: #090909;'
-    4090 => '    background-color: #090909;'
-    4107 => '  margin-bottom: 20.000000006px;'
-    4126 => '  margin: 20.000000006px 0;'
-    4218 => '  margin: 20.000000006px 0;'
-    4398 => '  margin-bottom: 20.000000006px;'
-    4425 => '  margin-bottom: 20.000000006px;'
-    4514 => '  height: 20.000000006px;'
-    4515 => '  margin-bottom: 20.000000006px;'
-    4526 => '  line-height: 20.000000006px;'
-    4753 => '  margin-bottom: 20.000000006px;'
-    4929 => '  margin-bottom: 20.000000006px;'
-    5478 => '  filter: progid:DXImageTrans...pe=1);'
-    5486 => '  filter: progid:DXImageTrans...pe=1);'
 )
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:75
FAILURES!
Tests: 507, Assertions: 690, Failures: 16.

Parsing when using cache causes problems

Parsing when using cache causes problems. Situation:

// Setup a parser instance with cache:
$parser = new ILess_Parser(array(), 
    new ILess_Cache_FileSystem(sys_get_temp_dir())
);

$parser->parseFile('/my/path/bootstrap2/bootstrap.less');
$css = $parser->getCSS();

After the first request to compile bootstrap2 the cache files are successfully written to disk.

When compiling bootstrap3 (not version 2) with the same setting for cache directory, the parser will throw an exception:

The variable `@icon-font-path` is not defined. (/my/path/bootstrap3/glyphicons.less, line: 13)

Compiling long url strings

I'm getting an issue which I can only seem to put down to the parser hanging when it tries to compile long url strings. i.e. url("...."). Specifically, I have a number of font-face declarations using WebType fonts with long strings for the font URLs, and ILess refuses to parse these.

Import reference fails under php 7

Import by reference test fails under php 7.

The test file: less.js/less/import-reference.less

There was 1 error:

1) ILess\Test\CachingTest::testCompilation with data set #24 ('/home/travis/build/mishal/ile...e.less', '/home/travis/build/mishal/ile...ce.css')

unserialize(): Error at offset 390 of 618 bytes
/home/travis/build/mishal/iless/lib/ILess/Node/ImportNode.php:333
/home/travis/build/mishal/iless/lib/ILess/Node/RulesetNode.php:1013
/home/travis/build/mishal/iless/lib/ILess/ImportedFile.php:159
/home/travis/build/mishal/iless/lib/ILess/FileInfo.php:93
/home/travis/build/mishal/iless/lib/ILess/Cache/Cache.php:68
/home/travis/build/mishal/iless/lib/ILess/Cache/FileSystemCache.php:150
/home/travis/build/mishal/iless/lib/ILess/Parser.php:118
/home/travis/build/mishal/iless/lib/ILess/Parser/Core.php:409
/home/travis/build/mishal/iless/tests/ILess/Test/Parser/ParsingTest.php:98

see: https://travis-ci.org/mishal/iless/jobs/86137704

separated from #62

Errors prevent compilation of Twitter Bootstrap v3 w/ some Bootswatches

When attempting to compile the 'United' Bootswatch v3.3.5+3 it with 'Unrecognised input' for the $endInfo->furthest = 628

// United 3.3.5
// Bootswatch
// -----------------------------------------------------

@web-font-path: "https://fonts.googleapis.com/css?family=Ubuntu:400,700";

.web-font(@path) {
  @import url("@{path}");
}
.web-font(@web-font-path);

// Navbar =====================================================================

.navbar {

  &-default {

    .badge {
      background-color: #fff;
      color: @navbar-default-bg;
    }
  }

  &-inverse {

    .badge {
      background-color: #fff;
      color: @navbar-inverse-bg;
    }
  }
}

@media (max-width: @grid-float-breakpoint-max) {

  .navbar {

    .dropdown-menu {
      a {
        color: #fff;
      }
    }
  }
}

Cache growth with parseString

parseString uses a dummy last modified time, which is okay on face value because cache signatures are based on actual rules and contexts. However the last modified time exists through the rule tree, so leaks through to the cache signature. Hence every time parseString is used, there's a new cache file.

I tested changing to something constant and unique. I don't think uniqueness was actually required, as this isn't the cache signature, but doesn't hurt performance much. It's a hack though. Maybe null would have been better, but then it would likely need knock-on changes so that null was always properly handled as a valid value.

diff --git a/flwg.com.au/sources_custom/ILess/Parser/Core.php b/flwg.com.au/sources_custom/ILess/Parser/Core.php
index 6a0e2f2..26392ca 100644
--- a/flwg.com.au/sources_custom/ILess/Parser/Core.php
+++ b/flwg.com.au/sources_custom/ILess/Parser/Core.php
@@ -157,7 +157,7 @@ class ILess_Parser_Core
         // create a dummy information, since we are not parsing a real file,
         // but a string comming from outside
         $this->env->setCurrentFile($filename);
-        $importedFile = new ILess_ImportedFile($key, $string, time());
+        $importedFile = new ILess_ImportedFile($key, $string, crc32($string));

         // save information, so the exceptions can handle errors in the string
         // and source map is generated for the string

Oh and fix spelling of 'coming' too, lol.

In the process of writing this up, I double checked myself, and I'm despairing a bit for 2 reasons...

  1. The cache signature is based on rules ($this->rules in Parser.php), so clearly in order to take out of the cache, parsing is needed. Seems the cache is not cacheing as much as it should. A crc32 or md5 of the actual code might be better. I haven't studied in detail, but it really seems inefficient to me.
  2. $this->rules is mega-bloated. This may be related to #2. Basically the same set of rules is there 1249 times with me, likely the same combinatorial explosion related to mixins.

Bug in logic

"I know that no computer app can just appear or develop by chance even if I will have a rest of 1 billion years."

Error: chance <> evolution.

Evolution is the third alternative to creation and chance:

  • Creation: a sentient being creates stuff deliberately.
  • Chance: a single(!) point in time where stuff just happened to fall into the right place.
  • Evolution: the continuous process of a) random variation; b) natural selection upon said variation and c) repetition.

Note how creation and chance require perfect conditions to happen ("a supreme being", "an impossible chance"), whereas evolution is an imperfect process of trial and error.

Catchable fatal error: Object of class ILess_FileInfo

I know this is incorrect syntax but the exception is not handled properly.

.test{
  background-color: darken("#ffffff",2%);
}

The full error is

Catchable fatal error: Object of class ILess_FileInfo could not be converted to string in /path_to_code/public_html/library/classes/shared/ILess/Exception.php on line 185

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.