ju1ius / css-parser Goto Github PK
View Code? Open in Web Editor NEWCSS parser for PHP
License: GNU Lesser General Public License v3.0
CSS parser for PHP
License: GNU Lesser General Public License v3.0
Runtime Notice: Non-static method ju1ius\Text\Encoding::convert() should not be called statically in /path/ju1ius/css-parser/lib/ju1ius/Css/Loader.php line 113
Any solution for that?
I noticed a small issue where if there are two css property declarations like so:
#right_nav ul li a.current{
padding:0px;
padding:0 0 0 35px;
}
What will happen is that the returned expanded padding css property will all be 0 i.e:
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom 0;
So I investigated the _canAddShorthandExpansion
function and it looks the condition on line: https://github.com/ju1ius/css-parser/blob/master/lib/ju1ius/Css/StyleDeclaration/ExpandShorthands.php#L271
Should be a <
(less than). The smaller the number the further up the deceleration and the more important it is right?
Basically, what is happening is that the latter is not set as the final property. Another example would be:
margin: 10px 12 px 14px 16px;
margin: 30px;
The latter should be the final margin property. From my investigation, I could only narrow it down to that function and the greater than sign.
I think when fonts are expanded into their long hand format the font-size values are only considered when they have units. Font size can be set using the strings such as "small", "large" etc. So on this line: https://github.com/ju1ius/css-parser/blob/master/lib/ju1ius/Css/StyleDeclaration/ExpandShorthands.php#L97
I made the crude change of this:
} else if($mValue instanceof Value\Dimension && $mValue->getUnit() !== null
|| in_array($mValue, array('xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'smaller', 'larger'))) {```
The above has managed to work for me so far.
I found a small typo here: https://github.com/ju1ius/css-parser/blob/master/lib/ju1ius/Css/StyleDeclaration/ExpandShorthands.php#L241
It should be list-style-type
.
In future, I'll submit pull requests. This a great project you've created.
PS. Maybe you should setup an email address on github so users can message you. I tried to congratulate you. :)
Hi,
Awesome library!
I noticed whilst testing that it doesn't handle comments that are in the form:
/** My comment */
Notice the extra asterik.
Same for
/*********************/
Hi,
I have noticed an issue with merge function in the StyleRule class. This is one of the CSS properties that this function tries to deal with:
CSS\Property Object
(
[name:CSS\Property:private] => background-color
[valueList:CSS\Property:private] => CSS\PropertyValueList Object
(
[separator:protected] => ,
[items:protected] => Array
(
[0] => CSS\Value\Color Object
(
[channels] => Array
(
[r] => 0
[g] => 0
[b] => 0
)
[mode:CSS\Value\Color:private] =>
)
)
)
[isImportant:CSS\Property:private] =>
)
However, it throws this error:
Fatal error: __clone method called on non-object in C:\PROJECT\svn\dev\vendor\julius\CSS\Value\Color.php on line 180
It seems to have an issue with Line 124:
if ($override) {
$aProperties[$name] = array(
'property' => clone $property,
'specificity' => $specificity
);
}
Can it clone the Color object?
Apologies if this is a basic question!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.