epubcheck icon indicating copy to clipboard operation
epubcheck copied to clipboard

CSS parsing of valid CSS files fails

Open mscofield0 opened this issue 2 years ago • 2 comments

I use TailwindCSS with my epub project to style the book. However, stuff that are usually legal that Tailwind produces, don't pass the epub checker's validator. I assume that the parser doesn't fully conform to the CSS standard, or there are some limitations in the EPUB standard that I'm missing.

  • An error occurred while parsing the CSS: Token "]" not allowed here.
/*
__________________
           vvvvvvv  */
abbr:where([title]) {
  -webkit-text-decoration: underline dotted;
          text-decoration: underline dotted;
}
  • Empty CSS variables fail parsing too (e.g. --tw-color: ;)
  • CSS font selector declaration uses unexpected font-size value "unset"
[type='file'] {
  background: unset;
  border-color: inherit;
  border-width: 0;
  border-radius: 0;
  padding: 0;
  font-size: unset; /* <------- */
  line-height: inherit;
}

mscofield0 avatar May 19 '22 10:05 mscofield0

Coming here with the same validation issues (and also specifically from Tailwind usage).

Without having dug too much, it looks like EPUBCheck uses SAC to parse and validate its CSS. On its page, there are concerning statements such as:

... CSS3 (currently under development) ...

and

The API is a beta version ...

Is there anything more up to date we can use?

For what its worth, Jigsaw (has online validator) does allow :where([attr]) and foo: unset; constructs. (No validator I have found correctly accepts empty-valued custom properties like --foo: ;, but the spec specifically says this case is valid.)

t-mart avatar Jul 05 '22 00:07 t-mart

EPUBCheck uses its own bespoke CSS parsing code. I'll look into how it can be changed to accept that syntax. It's definitely a bug (false-positive).

rdeltour avatar Jul 05 '22 07:07 rdeltour

I just want to add that I've run into a similar validation error with :has(): "An error occurred while parsing the CSS: Token ">" not allowed here."

section.subchapter:has(> h2) { ... }

Epubcheck 4.2.6 and Epubcheck 5.0.0-beta-2 both return this error.

GyldenMort avatar Sep 28 '22 06:09 GyldenMort