Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 02-27-2011, 08:03 AM   #1
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
Adding page breaks in Calibre breaks ePubcheck validation

Hi,

I have an ePub which I have exported from InDesign (without page breaks).

This ePub passes the ePubcheck validation (except for the date, which is fixed if I run Calibre's epub-fix commandline tool).

Next, I add page breaks in calibre by converting from ePub to ePub, and adding page breaks before chapter openings.

This works fine, and I'm able to view the ePub with the correct page breaks in ADE and calibre's viewer.

However, the ePub no longer passes the ePubcheck validation. Each page break (there are 150 of them) produces this error:

Error: test.epub/OEBPS/Test_split_125 [any number between 1 and 150].xhtml<16>: element "a" from namespace "http://www.w3.org/1999/xhtml" not allowed in this context

running calibre's epub-fix does not help in this case.

If anyone has an idea what's wrong and what I can do to fix this, that would be very kind.

Thanks,
Ariel
bookraft is offline   Reply With Quote
Old 02-27-2011, 09:32 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,427
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Wrap the <a> element in a <div>
kovidgoyal is online now   Reply With Quote
 
Enthusiast
Old 02-27-2011, 11:44 AM   #3
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
Quote:
Originally Posted by kovidgoyal View Post
Wrap the <a> element in a <div>
Many thanks. You mean: <div><a></a></div>, right?

Any way of doing this automatically? That is, the ePub has 150 chapters and each has an anchor. Can calibre search and replace throughout the ePub? If not, any ideas what program could do this simply and easily?

By the way, is this a problem with calibre or with epubcheck? If it's a problem with epubcheck, any chance of getting the epub-fix to fix this as well?

Many thanks for an amazing piece of software!

Ariel
bookraft is offline   Reply With Quote
Old 02-27-2011, 12:00 PM   #4
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80446
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
There's a search and replace option available in the conversion settings. I'm not sure of the order in which the different options are called in the conversion pipeline, though, it may be that you need to do two passes, the first one for adding the pagebreaks, the second for wrapping the tag.
Manichean is offline   Reply With Quote
Old 02-27-2011, 12:25 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,427
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Change the chapter detection to detect a top level element instead of an <a> tag and you wont have the problem in the first place.
kovidgoyal is online now   Reply With Quote
Old 02-27-2011, 12:38 PM   #6
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
Thank you both.

I've got the following find:

(<a.+/a>)

for the replace, I'm not sure how to indicate the find field. In InDesign you'd use $1, $2 etc. but it's not working here. I'm looking for something like:

<div>$1</div>

Any help welcome.

@kovidgoyal:

The way I'm guaranteeing page breaks in the right place is by applying a character style to some text, and, in calibre, adding a page break before that character style. The <a> tages are link destinations for the table of contents that's part of the ebook.

Is that not the best way to do it?

Thanks,
Ariel
bookraft is offline   Reply With Quote
Old 02-27-2011, 12:44 PM   #7
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80446
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
My advice re search and replace: Forget what I said earlier, go with Kovid's idea. (Just for the record, though, backreferences in Python style regexes are made with backslashes, so you probably want to use something like <div>\1</div>)
Manichean is offline   Reply With Quote
Old 02-27-2011, 12:46 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,427
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I don't know about what indesign is capable of, but generally speaking, you should have chapter breaks on a block level element like a heading or a pragraph, not on an inline element like an anchor.
kovidgoyal is online now   Reply With Quote
Old 02-27-2011, 01:19 PM   #9
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
I see. A character style is presumably also an inline element. So I'll try and base it on a paragraph style (or several).

Thanks, and thanks Manichean for your help.

Ariel
bookraft is offline   Reply With Quote
Old 02-27-2011, 01:34 PM   #10
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
Adding div tags doesn't help. Epubcheck simply gives the same warning as before:

Error: test.epub/OEBPS/Test_split_125 [any number between 1 and 150].xhtml<16>: element "div" from namespace "http://www.w3.org/1999/xhtml" not allowed in this context

Here's the code from the beginning of one of the 150 files:

Code:
<?xml version="1.0"?>
<!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>
  <title>Psalms ePub Georgia</title>
  <link href="../Styles/stylesheet1.css" rel="stylesheet" type="text/css" />
  
<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }
                @font-face {
    font-family: "Georgia";
    font-style: normal;
    font-weight: normal;
    src: local(Georgia)
    }
</style>
</head>

<body class="calibre">
  <p class="awpsalmheader" id="calibre_toc_8"><span class="awpagebreak" id="calibre_pb_8">PSA</span><span>LM SIX</span></p>

  <div class="calibre1">
    <a class="calibre2" id="psalm-six-anchor"></a>
  </div>

  <p class="awnormal17ptafter"><span>A composition for chorus and strings, a psalm of David:</span></p>
As for the suggestion of using paragraph styles for the page breaks, it's not so practical. Although the document is well structured in InDesign, some page breaks must come before pargraph styles that are used elsewhere, and where a page break is not necessary.

hmm...
bookraft is offline   Reply With Quote
Old 02-27-2011, 01:43 PM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,427
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
div tags are most definitely allowed as children of body, so your error is complaining about something else.

I suggest using flightcrew instead of epubcheck, it tends to have more helpful error messages.
kovidgoyal is online now   Reply With Quote
Old 02-27-2011, 01:47 PM   #12
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
Thanks again. I'll try flightcrew.
bookraft is offline   Reply With Quote
Old 02-27-2011, 05:22 PM   #13
bookraft
Junior Member
bookraft began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2011
Device: none
Flightcrew didn't help.

I used calibre to split the file before a designated paragraph style rather than a character style and that also didn't help.

On the other hand, I've just used Sigil to do the same thing, inserting a chapter break before each paragraph, and this works.

So it seems that calibre isn't working well with embedded anchors for some reason.

Thanks,
Ariel
bookraft is offline   Reply With Quote
Old 02-27-2011, 06:35 PM   #14
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 36,215
Karma: 17169472
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Since you are making an ePub eBook, why do you need anchors for the chapter titles? Are these to link back to some internal ToC? It's ePub. ePub doesn't need that. It has an external ToC. So you can do away with the anchors and any internal ToC.
JSWolf is offline   Reply With Quote
Old 02-27-2011, 09:02 PM   #15
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,781
Karma: 12516053
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by bookraft View Post
I used calibre to split the file before a designated paragraph style rather than a character style and that also didn't help.

On the other hand, I've just used Sigil to do the same thing, inserting a chapter break before each paragraph, and this works.

So it seems that calibre isn't working well with embedded anchors for some reason.
You brought up some fair questions. As JSWolf says there are many ways to skin a cat. Calibre works great on h1, h2, h3 tags etc... to create proper external TOC for ePubs. It also seems based on your info that it does great with functionally splitting things the way you like but ePubcheck left you wanting.

Calibre is not a ePub creation / publishing tool. It is a ebook management tool and it also does a great job of converting books from one format to another format. This conversion process promises to create a readable book for our use.

Most likely further questions about refining your books to pass flightcrew or ePubcheck should be asked in the ePub forum.

That said, if you think something you run into in the future is a bug or you need help doing or understanding something don't hesitate to bring it up in this forum. You can also request enhancements or report bugs through calibre's site, learn how here.

Good Luck with your projects.

Last edited by DoctorOhh; 02-27-2011 at 09:06 PM.
DoctorOhh is offline   Reply With Quote
Reply

Tags
epubcheck, error, page breaks, validation

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mobi page breaks in Calibre viewer DaleDe Calibre 3 04-04-2011 01:58 AM
Force Calibre not to add Page Breaks on H1 and H2 Tags jloakes Calibre 2 11-18-2010 04:08 PM
Adding chapter breaks by number of pages/lines raptir Calibre 8 10-22-2009 12:11 PM
Page breaks not working EnsignRicki Calibre 0 06-26-2009 11:47 AM
Page breaks enarchay Calibre 18 05-31-2009 06:57 PM


All times are GMT -4. The time now is 11:42 AM.


MobileRead.com is a privately owned, operated and funded community.