Re: [csswg-drafts] Allow comment indicators (`/*` and `*/`) to be nested. (#10768)

This is the sort of thing you can add when you're *designing* a language, but can't actually add later, because people end up relying on comment parsing. Unfortunately, CSS went with C rules for this, and we're stuck with them.

For example, it's *not uncommon* for me to exploit comment parsing to get easy binary toggling of sections when I'm experimenting, like:

```css
/**
this area is initially commented
/*/
this area is initially active
/**/
```

Because then, with the addition of a single character to the end of the first line:


```css
/**/
this area is now active
/*/
this area is now commented
/**/
```

This unfortunately means that to comment out large sections that might contain comments themselves, you need the help of a smart editor. Or you can use CSS parsing against itself - any of the brace pairs can effectively toggle stuff by making them invalid (with `{}` being the easiest, as it triggers rule parsing and doesn't need a closing `;` to restart normal parsing).

```css
{
this stuff is *basically* commented out, since the whole block is invalid and dropped
{
and you can nest them
}
so this is still commented out too
}
body::before { content: "normal content here"; }
```

It's even parsing-aware, so you can have, say, a string that contains an unmatched `}` and it won't accidentally close your comment, like a string with `*/` will in normal CSS.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10768#issuecomment-2305490458 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 22 August 2024 19:34:42 UTC