Skip to content

Allow comment indicators (/* and */) to be nested. #10768

@RokeJulianLockhart

Description

@RokeJulianLockhart

Specification Name and URI

  1. Please tag the issue title with the spec's short name, like [css-foo] (this is the name from the spec URL, without a level number unless the issue is specific to that level). If you're proposing a new feature that doesn't obviously fit in an existing spec, skip this part — don't make something up.

  2. Please link to the spec section you're talking about, or at least the spec.

I think this could reasonably be attributed to CSS Syntax Module Level 3:

If the next two input code point are U+002F SOLIDUS (/) followed by a U+002A ASTERISK (), consume them and all following code points up to and including the first U+002A ASTERISK () followed by a U+002F SOLIDUS (/), or up to an EOF code point. Return to the start of this step.

Improvement

Please be specific (in the title and issue) about what you want to change: “make it better” means different things to different people!

I cannot utilize a custom tag like I can in HTML (<comment>, for instance) which means that for this functionality, I am dependent upon preprocessors, like LESS. However, that's not applicable to mere HTML files.

Luckily, some IDE extensions automatically break the tags in non-standardized manners, like https://github.com/philsinatra/NestedCommentsVSCode/blob/9c25135847af99c89e66b14e7396a3bf2b0d7cf0/README.md#html-syntax:~:text=Examples-,HTML%20Syntax,%3C/main%3E%20%2D%2D%3E,-CSS%20Syntax. However, this is again a problematic barrier to entry, because it assumes that the user's IDE is advanced enough to:

  1. Provide this functionality.
  2. Automatically make the necessary modifications as sections are uncommented and commented, lest the user need to constantly invoke the relevant command.

Other languages, like PowerShell and C++, partially remediate this by providing a non-inline comment indicator. However, this isn't applicable to CSS by design, for it would break its ability to be entirely minified. Consequently, the sole alternative is to permit nested comments.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions