-
Notifications
You must be signed in to change notification settings - Fork 136
Add parse_whitespace_separated() #105
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
Comments
It provides a lot more than that: https://servo.github.io/rust-cssparser/cssparser/struct.Parser.html The most basic thing is calling the In fact even comma-separated let top = try!(parse_rect_argument(input));
try!(input.expect_comma());
let right = try!(parse_rect_argument(input));
try!(input.expect_comma());
let bottom = try!(parse_rect_argument(input));
try!(input.expect_comma());
let left = try!(parse_rect_argument(input)); Now, in this case you want to allow https://drafts.fxtf.org/css-masking-1/#funcdef-clip-rect
(Emphasis added.) To do this, you’ll need to parse the first argument, then see if there’s a comma. If so, require commas between the rest of the arguments. If not, require that there is no comma. Note that the let top = try!(parse_rect_argument(input));
let right;
let bottom;
let left;
if input.try(|input| input.expect_comma()) {
right = try!(parse_rect_argument(input));
try!(input.expect_comma());
bottom = try!(parse_rect_argument(input));
try!(input.expect_comma());
left = try!(parse_rect_argument(input));
} else {
right = try!(parse_rect_argument(input));
bottom = try!(parse_rect_argument(input));
left = try!(parse_rect_argument(input));
} I’m closing this since I don’t think a change in rust-cssparser is needed, but feel free to ask more questions. |
For servo/servo#9283, Servo needs to be able to parse
rect(...)
values with values separated purely by spaces, for example:rect(0, 0, 5, 5)
.However,
cssparser
only providesparse_comma_separated()
. I looked into it a little, and it's a little challenging:parse_{x}_separated()
will parse up to a Delimiter, of which all 8 slots of the byte are in use. It is not possible to have more than onetrue
bit per byte, because some bitwise OR logic is used which depends on mutual exclusivity.Additionally, three different
Delimiter
s would need to be added: space, tab, newline.So, I'd love to implement this, but I'll need some pointers :)
The text was updated successfully, but these errors were encountered: