Skip to content

[TASK] Allow whitepace parsing to be stopped at EOL#1505

Open
JakeQZ wants to merge 1 commit intomainfrom
task/parse-comments-at-eol
Open

[TASK] Allow whitepace parsing to be stopped at EOL#1505
JakeQZ wants to merge 1 commit intomainfrom
task/parse-comments-at-eol

Conversation

@JakeQZ
Copy link
Collaborator

@JakeQZ JakeQZ commented Feb 11, 2026

The whitespace parsing includes extraction of comments to be associated with the content.

There are cases where the comment is after the content, but should be associated with the preceding rather than the following. This will help achieve that.

The whitespace parsing includes extraction of comments to be associated with
the content.

There are cases where the comment is after the content, but should be
associated with the preceding rather than the following.
This will help achieve that.
@coveralls
Copy link

Coverage Status

coverage: 73.023% (+0.04%) from 72.984%
when pulling e1a0e9b on task/parse-comments-at-eol
into 252bbe1 on main.

@oliverklee
Copy link
Collaborator

I don't quite understand this yet: Why should consuming whitespace stop at a linefeed, i.e., what makes the linefeed whitespace character special?

@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 11, 2026

I don't quite understand this yet: Why should consuming whitespace stop at a linefeed, i.e., what makes the linefeed whitespace character special?

It's so we would be able to correctly attribute comments to the relevant declarations as 'before' and 'after' (or 'leading' and 'trailing'), e.g.

/* This is a comment about the font size. */
font-size: 14px;
color: green; /* This is a trailing comment about the colour.  It has nothing to do with the width. */
/* This is a comment about the width. */
width: 50%;

So after parsing a property declaration, we can consume whitespace and any trailing comments up to the next line feed. Then we parse the next property declaration, consuming possibly more whitespace and any leading comments.

It's a building block towards solving #663 and #1445.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants