0

Epubcheck reports an error for a paragraph like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
     <meta content="text/html; charset=utf-8" http-equiv="content-type" />
     <title>Title</title>
     <link rel="stylesheet" type="text/css" href="foo.css" />
  </head>
  <body>
      <p class="flush">"Time flies <span style="red">when</span> you're having a good time"</p>
  </body>
</html>

The error comes back as:

Position 1
An error occurred while parsing the CSS: Premature end of grammar (expecting: :).

There are no other errors in the EPUB.

I don't know how to fix this error. It's the first time I've encountered it.

Worthy of note: this same epub file runs through Amazon Kindlegen with no errors.

4
  • 1
    You appear to be citing the wrong piece of code, as epubcheck shouldn't be parsing CSS in this file (your only CSS is in the <link > reference, and that's going to be handled separately).
    – Auspex
    Feb 26, 2016 at 14:28
  • I edited my answer below to clarify.
    – Paulb
    Feb 26, 2016 at 15:42
  • Actually the answer was clear. But you edited this question, too, because there were no style attributes in your original post.
    – Auspex
    Feb 27, 2016 at 22:49
  • I know. The question was confusing, because as I asked it originally it was very different from what the eventual problem turned out to be. With new knowledge of what the problem really was I edited it for clarity.
    – Paulb
    Feb 28, 2016 at 13:18

2 Answers 2

1

I posted an issue at the epubcheck site.

Someone there knew right away what the problem was.

This is acceptable:

<p>Text <span class="red">red</span> regular.</p>

This is acceptable:

<p>Text <span style="color:red">red</span> regular.</p>

This is not acceptable, and is what I had:

<p>Text <span style="red">red</span> regular.</p>

It was hard for me to figure out because the character position reported by epubcheck was at the beginning of the paragraph, far away from the actual error.

3
  • you mean you changed class to style don't you?
    – Anthon
    Feb 23, 2016 at 4:33
  • No, he means style="red" is, indeed, invalid, but class="red" is not. However, I don't see any problems in his original post, because there isn't any place that it should have been parsing CSS.
    – Auspex
    Feb 26, 2016 at 14:25
  • <span class="red"> Whenever I make classes I make sure the class name is not the same as any keyword, to reduce confusion. So I would call the style 'redclass' or something like that.
    – Bulrush
    May 31, 2016 at 13:01
0

<p class="flush">"Time flies <span style="red">

"red" is not a valid CSS style. The style should be <span style="color:red;">

This also works: <span style="color:red; font-weight:bold;">

But in an epub, which uses XHTML, I always used classes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.