Open tomcur opened 2 days ago
We should link to the relevant spec sections, especially regarding the handling of trailing items after
#rrggbbaa
.
I'm not aware of an authoritative source on this, it's possible one exists, or perhaps there's prior art we can follow.
Hmm. I presumed that the css specs would specify this. I can't imagine that e.g. border: #ffff00ff10px solid
would be valid for a 10 pixel border. Although admittedly, I've not tried it.
The unparsed remainder of the string is indicated in the return value.
Resolves #60.
The existing function
parse_color
now returnsParseError::ExpectedEndOfString
if there are trailing characters. Some choices could be made differently:#f00fa
the errorParseError::WrongNumberOfHexDigits
is returned. It could instead parse as#f00f
with trailinga
. The current implementation is consistent with parsingident
to the longest string and then checking for matches.ParseError::InvalidHexDigit
, as it is ambiguous whether the character was intended as a hex digit or is the start of the trailing string.#fffffftr
is parsed as#ffffff
with trailingtr
. This causes a slightly worse error for the full-string-consumingparse_color
, namelyParseError::ExpectedEndOfString
. We could haveparse_color
still returnParseError::InvalidHexDigit
for that case, but then the two functions have slightly different parsing behavior, which is not ideal (the prefix parse might succeed, whereas the full parse fails with an error different thanExpectedEndOfString
).