Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't parse number sign character #6

Open
radarfox opened this issue Jun 24, 2019 · 2 comments
Open

Doesn't parse number sign character #6

radarfox opened this issue Jun 24, 2019 · 2 comments

Comments

@radarfox
Copy link

From the CSS specification:

The format of a length value is an optional sign character ('+' or '-', with '+' being the default) immediately followed by a number...

Current output:

  • -1px => [{"type":"ident","string":"-1px"}]
  • -1 => [{"type":"ident","string":"-1"}]
  • -0 => [{"type":"ident","string":"-0"}]
  • +0 => throws failed to parse near +0...
  • +1 => throws failed to parse near +1...
  • +1px => throws failed to parse near +1px...

Expected output:

  • -1px => { type: 'number', string: '-1px', unit: 'px', value: -1 }
  • -1 => { type: 'number', string: '-1', unit: '', value: -1 }
  • -0 => { type: 'number', string: '-0', unit: '', value: -0 }
  • +0 => { type: 'number', string: '+0', unit: '', value: 0 }
  • +1 => { type: 'number', string: '+1', unit: '', value: 1 }
  • +1px => { type: 'number', string: '+1px', unit: 'px', value: 1 }
@tj
Copy link
Member

tj commented Jun 24, 2019

Post CSS is more or less the same as Rework (but actively maintained), you might be better off using that these days

@radarfox
Copy link
Author

radarfox commented Jun 26, 2019

Thanks for the response, but it seem to me, that Rework doesn't parse the values. All I need is to convert "-1px" into {value: -1, unit: "px"}.

In Rework i need to do something like * {top: -12px} and all I get is {property: "top", type: "declaration", value: "-12px"} which i useless to me.

Or am I missing something?

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

No branches or pull requests

2 participants