Skip to content

retain CSSList and Rule comments when rendering CSS #351

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 7 commits into from
Dec 28, 2021

Conversation

Ruud68
Copy link
Contributor

@Ruud68 Ruud68 commented Dec 23, 2021

Hi,
was banging my head against the wall as my css comments would vanish when using a autoprefixer repo that utilizes this repo.
Found out that the issue was that comments are only partly implemented in this repo: they are recognized, but when rendering the parsed css code they are not added back.

So I rolled up my sleeves and did this PR.

This PR does two things:

  1. fix the comments implementation as only the first comments where taken and not the subsequent comments in a CSSList
  2. adds the comments back into the rendered CSS (as also requested in Parse Comments? #38 )

So this is my first PR in this repo, would love to have some feedback / discussion / tests :)

Thanks in advance,
regards, Ruud

@oliverklee
Copy link
Collaborator

@Ruud68 Thanks for contributing! ❤️

Two things:

  • If this PR fixes two problems, is there a way we could separate it into two PRs?
  • I'd really like to have this covered with tests (that fail without the change and pass with it). Would you be willing to add those?

@@ -106,7 +106,6 @@ public static function parse(ParserState $oParserState)
while ($oParserState->comes(';')) {
$oParserState->consume(';');
}
$oParserState->consumeWhiteSpace();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix: remove this otherwise 'next' comment will be not set

@Ruud68
Copy link
Contributor Author

Ruud68 commented Dec 23, 2021

@oliverklee the fix is actually a very small one, I have added it as a comment to the code in the PR.
As for the tests: I have no idea how to do that and how to test if the changes to the tests are correct. I need to check how that is done

@oliverklee
Copy link
Collaborator

@Ruud68 I'll check what would be a good place for you to start with the tests.

@Ruud68
Copy link
Contributor Author

Ruud68 commented Dec 23, 2021

okay thanks @oliverklee I spent greater part of the day reverse engineering the code for these changes (not documented) and had a quick look at the unit tests. I do not think this will be a quick add for me (the tests) :(

@Ruud68
Copy link
Contributor Author

Ruud68 commented Dec 24, 2021

@oliverklee learned a lot :) did some small changes and fixed unittesting.... I hope :)

@sabberworm
Copy link
Collaborator

Thanks @Ruud68 for the great work! I took the liberty of making rendering comments optional (by way of a OutputFormat setting), defaulting to off, for backwards-compatibility.

@sabberworm sabberworm merged commit 9c89b95 into MyIntervals:master Dec 28, 2021
@Ruud68
Copy link
Contributor Author

Ruud68 commented Dec 29, 2021

Thanks @Ruud68 for the great work! I took the liberty of making rendering comments optional (by way of a OutputFormat setting), defaulting to off, for backwards-compatibility.

My pleasure, glad I could contribute. making it optional is definitely a good option :)

@Ruud68 Ruud68 deleted the retain-comments branch December 29, 2021 11:17
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.

3 participants