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

Migration from Less - handling of double slash comments #102

Open
chrisdeeming opened this issue Mar 8, 2024 · 2 comments
Open

Migration from Less - handling of double slash comments #102

chrisdeeming opened this issue Mar 8, 2024 · 2 comments

Comments

@chrisdeeming
Copy link

This isn't a dealbreaker, but thought I'd ask the question.

// avatars
.avatar
{
    // overflow: hidden;
    border-radius: var(--radius-avatar, 100vw);
}

With Less, this would be output as:

.avatar
{
    border-radius: var(--radius-avatar, 100vw);
}

It looks like we can use the declaration_preprocess event to strip out properties that start with //.

Are there any events that would enable us to strip out the others, or convert them to CSS comments?

@chrisdeeming
Copy link
Author

This works, I guess?

$process->on('capture_phase0', function (\CssCrush\Process $process)
{
	$process->input->string = preg_replace('/^\s*\/\/.*/m', '', $process->input->string);
	$importer = new \CssCrush\Importer($process);
	$process->string = new \CssCrush\StringObject($importer->collate());
});

We're probably just going to pre-process the template before passing it to crush. Though this highlights that perhaps an event that allows you to modify the input could be useful for others.

@peteduel
Copy link

peteduel commented Mar 8, 2024

This preprocessor only handles the comment style standard to CSS /* */, as staying close to the standard is a design goal

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