Skip to content

fix: handle whitespace between variable and colon #101

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

Merged
merged 1 commit into from
May 28, 2018

Conversation

e-cloud
Copy link
Contributor

@e-cloud e-cloud commented Mar 23, 2018

the variable declaration in less is somehow similar to at rule in css, makes its detection more complicated.

fix #92 , similar PR as #100. But this might be more generic.

Please check one:

  • New tests created for this change
  • Tests updated for this change

This PR:

  • Adds new API
  • Extends existing API, backwards-compatible
  • Introduces a breaking change
  • Fixes a bug

@shellscape
Copy link
Owner

shellscape commented Mar 23, 2018

@e-cloud @davidyorr I'll let you all hash this out. I'm impartial to one solution over another, but don't want to get in the middle and ruffle any feathers. you guys choose which PR is more fitting, and I'll go with that one.

@davidyorr
Copy link
Contributor

It doesnt matter to me, theyre almost the same solution anyway. This PR is probably a bit cleaner to read because it makes use of the globals file.

I did think of a few edge cases that would fail though. (in both PRs)

// @page with no whitespace
@page:left { }
// variable name starting with @page and extra whitespace
@pageWidth : 1080px;
// @page as a variable name without pseudo class and extra whitespace
@page : 1080px;

I came up with a fix for those cases but im not sure the best way to add on to this PR.

@e-cloud
Copy link
Contributor Author

e-cloud commented Mar 24, 2018

@davidyorr After a small altering, the second case is handled now.

The first will be also parsed as non-variable, but will not be parsed as atrule. That's a deeper problem inside postcss.

The third problem is unresolvable via simple approach. Those ambigious variables should seldom exist.

@e-cloud
Copy link
Contributor Author

e-cloud commented Mar 31, 2018

@shellscape @davidyorr any further reaction?

@shellscape
Copy link
Owner

I leave it to you two to reach a consensus. I'll merge whichever you both agree on.

@davidyorr
Copy link
Contributor

the new pageSelectorPattern doesn't work, it'll fail to parse variables starting with "page" that also have extra whitespace before the colon, something like @pagea :"test";

i think you might've meant pageSelectorPattern = /^@page[\W]+/;

@e-cloud
Copy link
Contributor Author

e-cloud commented Apr 3, 2018

@davidyorr you're right, my mistake.

the variable declaration in less is somehow similar to at rule in css, makes its detection more complicated.
@alexander-akait
Copy link

/cc @e-cloud @davidyorr what is status, we need this fix for prettier, thanks!

@davidyorr
Copy link
Contributor

@shellscape i think this PR should be good to merge

@e-cloud
Copy link
Contributor Author

e-cloud commented May 26, 2018

@shellscape could you have a look and perhaps make a new release?

@shellscape
Copy link
Owner

@e-cloud @davidyorr @evilebottnawi will this be a breaking change for users reliant upon the previous processing patterns before the fix is applied? Need to know for the release process.

@alexander-akait
Copy link

@shellscape it is bug fix, because by Less spec allor to using whitespace before :. People who use this bug can get breaking change.

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.

Spaces between variable name and : are not handled
4 participants