Skip to content

Conversation

@raxbg
Copy link
Contributor

@raxbg raxbg commented Nov 13, 2019

Parsing numbers written in scientific notation raises UnexpectedTokenException. This PR fixes this.

It might be a good idea to separate the number parsing and rendering from the Size class, however this will break backwards compatibility, so it might have to wait for a new major version release. Otherwise the numbers will have to extend Size...

@sabberworm
Copy link
Collaborator

It might be a good idea to separate the number parsing and rendering from the Size class, however this will break backwards compatibility, so it might have to wait for a new major version release. Otherwise the numbers will have to extend Size...

I’m not exactly sure what you mean. Size is exactly designed to handle numbers… But I agree that we should probably store additional metadata about how the size was formatted originally and provide ways for OutputFormat to determine if the output should be normalized (and to what) or output as it was input.

$sSize .= $oParserState->consume('-');
}
while (is_numeric($oParserState->peek()) || $oParserState->comes('.')) {
while (is_numeric($oParserState->peek()) || $oParserState->comes('.') || $oParserState->comes('e+', true) || $oParserState->comes('e-', true)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I’m not mistaken, the + isn’t mandatory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Fixed.

@raxbg
Copy link
Contributor Author

raxbg commented Nov 13, 2019

I was thinking of a Number class that can be used to parse/output numbers. Size can use Numbers to store the numeric portion of its numbers. Right now Size is a little weird, because it holds all kinds of numbers even colors instead of having a Color that holds Number objects for its numeric parts. Having this further separation will make it simpler for third parties when working with plain numbers, sizes and colors generated by the parser.

@sabberworm
Copy link
Collaborator

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 3
           

Complexity increasing per file
==============================
- lib/Sabberworm/CSS/Value/Size.php  2
         

See the complete overview on Codacy

background-color: rgba(62,174,151,3.0418206565232E+21);
z-index: 3.0418206565232E-2;
font-size: 1em;
top: 1.923478e2px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,6 @@
body {
background-color: rgba(62,174,151,3.0418206565232E+21);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,6 @@
body {
background-color: rgba(62,174,151,3.0418206565232E+21);
z-index: 3.0418206565232E-2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sabberworm sabberworm merged commit 81897e7 into MyIntervals:master Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants