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

Parse multiline silent comments as unified blocks #109

Open
nex3 opened this issue Aug 10, 2020 · 3 comments
Open

Parse multiline silent comments as unified blocks #109

nex3 opened this issue Aug 10, 2020 · 3 comments

Comments

@nex3
Copy link
Contributor

nex3 commented Aug 10, 2020

Currently this package parses each line of a silent //-style comment as a separate Comment object. In practice, users usually think of comments on adjacent lines as part of a single block, so it would be useful if this parser represented them as a single comment object. This would make downstream processing like documentation generation or stylelint/stylelint#4886 easier as well.

Note: Dart Sass also internally represents adjacent (block-level) silent comment lines as a single object, so you can look to its parsing logic for inspiration.

@ai
Copy link
Member

ai commented Aug 10, 2020

Yeap. It will be a nice feature.

PR is welcome since after PostCSS 8 release I will busy with Browserslist.

@hudochenkov
Copy link

I think proposed change would be unfortunate for tools, which use control comments (stylelint, Autoprefixer, Prettier, etc).

In CSS we have 3 separate comment:

/* a */
/* stylelint-disable */
/* b */

If we convert them to Sass:

// a
// stylelint-disable
// b

And then back to CSS (virtually, it just easier to understand what grouping of comments would do in postcss-scss):

/* a
stylelint-disable
b */

This is completely different thing, which is not important for Sass compiler, but is important for other tools. All these tools would need to change their code to parse every comment if there a line which starts with control words, etc.

@nex3
Copy link
Contributor Author

nex3 commented Sep 14, 2020

It's specifically for stylelint that we're trying to add this. I'd expect an inline comment that's intended to be a distinct chunk of text from another adjacent inline comment to be separated by an empty line.

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

3 participants