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

Fix algorithm to find balanced var() pairs #112

Merged
merged 3 commits into from
Apr 24, 2020

Conversation

Poetro
Copy link
Contributor

@Poetro Poetro commented Dec 9, 2019

Follow-up to PR #112

Fix #114

The parenthesis matching was not checking the right balance before.
For the declaration value var(--box-shadow, 0px 2px 8px 0px rgba(0, 0, 0, 0.5)) it would extract the following parts

{
  "pre": "",
  "body": "--box-shadow, 0px 2px 8px 0px rgba(0, 0, 0, 0.5",
  "post": ")"
}

as it finds the var( look for the closing ) token, which it then finds just after 0.5. Instead it should look for ( ) pairs, and check if the opening ( is after var. This way in the previous case, it would find:

{
  "pre": "",
  "body": "--box-shadow, 0px 2px 8px 0px rgba(0, 0, 0, 0.5)",
  "post": ""
}

@MadLittleMods MadLittleMods merged commit bbbd64d into MadLittleMods:master Apr 24, 2020
MadLittleMods added a commit that referenced this pull request Apr 24, 2020
@MadLittleMods
Copy link
Owner

Thanks for the contribution @Poetro! Sorry for the delay 🙇

Appreciate the clear code and tests ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parenthesis problem
2 participants