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

Rewrite for current Syntax Level 3 #13

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

Conversation

riking
Copy link

@riking riking commented Mar 20, 2018

I needed a tokenizer that properly skipped bad-string and bad-url without erroring out, so I just rewrote the whole thing /shrug

Expanded the tests and includes fuzz testing.

@kisielk
Copy link
Contributor

kisielk commented Mar 21, 2018

Wow, definitely thorough :)

So do you think this should just be put alongside the existing scanner package, or should it supersede it?

}

// Attempt to turn the token back into a CSS string.
func (t *Token) WriteTo(w io.Writer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing go vet to raise an error in the Travis tests. The signature should be func (t *Token) WriteTo(w io.Writer) (int64, error) with the same kind of semantics as the interface (return the number of bytes written and any error).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I figured that was going to happen. Do you think I should just do Render() string or implement the byte counting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the least it needs to return the error from the underlying writer, so you might as well include the byte counting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be pretty easy if you eliminate the uses of fmt and just use io.WriteString everywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up using a helper function, called it stickyWriteString(n *int64, err *error, w io.Writer, s string) after the concept of "sticky errors". Not the best name but /shrug

Also updated the README and did another pass over documentation.

@riking riking changed the title Rewrite for current Syntax Level 3 draft Rewrite for current Syntax Level 3 Mar 25, 2018

// Handle first character
// dashes allowed at start only for TokenIdent-ish
// eE not allowed at start for Dimension
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reasoning behind this? It causes something like asd {sdf: 3em} to incorrectly turn into asd {sdf: 3\65 m} when re-encoding.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was referenced somewhere as being due to 1e9px or something like that. Check the spec?

@kisielk kisielk removed their assignment Dec 7, 2022
@coreydaley
Copy link
Contributor

@riking This pull request has some complex conflicts that need to be resolved and then we can review it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

5 participants