Skip to content

Conversation

@outoftime
Copy link
Contributor

This stylesheet:

p {
   padding: 1px 1px 1px 1px 1px;
}

Yields an “extra tokens after value” error from PrettyCSS. This is
what we’d expect, since there is an extra 1px at the end of the value,
which is not a valid way to write padding.

However, this will generate the same error:

p {
   padding: 1px
   margin: 4px;
}

Since CSS is insensitive to newlines, the margin on the second line
appears to be a continuation of the value for padding on the first
line.

We can heuristically identify situations where the “extra tokens after
value” error is the result of a missing semicolon:

  • The token that fails to parse is the first non-whitespace string on
    its line
  • The previous line does not end in a semicolon

So, we now get good error messages for each of these situations:

This stylesheet:

```css
p {
   padding: 1px 1px 1px 1px 1px;
}
```

Yields an “extra tokens after value” error from PrettyCSS. This is
what we’d expect, since there is an extra `1px` at the end of the value,
which is not a valid way to write `padding`.

However, this will generate the same error:

```css
p {
   padding: 1px
   margin: 4px;
}
```

Since CSS is insensitive to newlines, the `margin` on the second line
appears to be a continuation of the value for `padding` on the first
line.

We can heuristically identify situations where the “extra tokens after
value” error is the result of a missing semicolon:

* The token that fails to parse is the first non-whitespace string on
  its line
* The previous line does not end in a semicolon
@outoftime outoftime merged commit 516b737 into popcodeorg:master Aug 14, 2016
@outoftime outoftime deleted the extra-tokens-vs-missing-semicolon branch August 14, 2016 16:30
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

Successfully merging this pull request may close these issues.

1 participant