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

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 07-24-2011, 11:32 AM   #1
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Fix TOC that points to wrong chapter?

Somehow, after multiple conversions between formats using Calibre, the TOC in a well-formatted book now always points to one chapter prior to where it is supposed to point. I'd like to fix this but am not entirely sure how. I tried putting header tags around the chapter titles in the hopes that that would allow Sigil to auto-detect the chapter titles, but not only is that very tedious (70-odd chapter book), but it also puts a break in the middle of the title, so the title takes up multiple lines. Is there a way to simply redirect where the links in the TOC point? Also, if I do this will I be safe when I convert from epub back to mobi using Calibre again? Thanks!
lunixer is offline   Reply With Quote
Old 07-24-2011, 02:02 PM   #2
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by lunixer View Post
Somehow, after multiple conversions between formats using Calibre, the TOC in a well-formatted book now always points to one chapter prior to where it is supposed to point. I'd like to fix this but am not entirely sure how. I tried putting header tags around the chapter titles in the hopes that that would allow Sigil to auto-detect the chapter titles, but not only is that very tedious (70-odd chapter book), but it also puts a break in the middle of the title, so the title takes up multiple lines. Is there a way to simply redirect where the links in the TOC point? Also, if I do this will I be safe when I convert from epub back to mobi using Calibre again? Thanks!
Question: Is the problem TOC inline (part of a Html page) or the normal 'catalog' one seen in the sidebar (that is the one seen in Sigils TOC editor (press f7) )?
theducks is online now   Reply With Quote
 
Enthusiast
Old 07-24-2011, 03:26 PM   #3
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by theducks View Post
Question: Is the problem TOC inline (part of a Html page) or the normal 'catalog' one seen in the sidebar (that is the one seen in Sigils TOC editor (press f7) )?
I'm not sure entirely what you mean, but I can tell you that when I press f7, the TOC editor does not recognize any chapters.
lunixer is offline   Reply With Quote
Old 07-24-2011, 04:27 PM   #4
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by lunixer View Post
I'm not sure entirely what you mean, but I can tell you that when I press f7, the TOC editor does not recognize any chapters.
That is the normal EPUB TOC that Sigil builds from <h#> tags (you have none)

That also tells me that the problem you see is with the Inline type, which is just another book page.

Sorry, I don't know how to do math (to do digit adjustment) with REGEX

If your paste one of your chapter headings (Entire line with tags, copied in Code View ), I might be able to suggest a REGEX for S&R that fould convert those to H# tags that Sigil will use for the standard TOC.
Then after that is working AND SAVED, if there is no special reason to keep the inline TOC, delete that (via the book browser) if it is a separate file.
Calibre can generate a new one from the EPUB, on conversion to Mobi.
theducks is online now   Reply With Quote
Old 07-24-2011, 04:32 PM   #5
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by theducks View Post
That is the normal EPUB TOC that Sigil builds from <h#> tags (you have none)

That also tells me that the problem you see is with the Inline type, which is just another book page.

Sorry, I don't know how to do math (to do digit adjustment) with REGEX

If your paste one of your chapter headings (Entire line with tags, copied in Code View ), I might be able to suggest a REGEX for S&R that fould convert those to H# tags that Sigil will use for the standard TOC.
Then after that is working AND SAVED, if there is no special reason to keep the inline TOC, delete that (via the book browser) if it is a separate file.
Calibre can generate a new one from the EPUB, on conversion to Mobi.
Here is a bunch of information from the top of one of the files. Thanks for the help. BTW, if it matters at all I am using the x64 Linux versions of both Calibre and Sigil, Calibre 0.8.11, Sigil 0.3.4.

EDIT: The line that is red is the actual chapter header.

Quote:
<?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>Priestess of the White</title>
<link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css" />

<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }

div.sgc-1 {height:0pt}
</style>
</head>

<body class="calibre" id="filepos178">
<div class="sgc-1" id="filepos16949"></div>

<div class="sgc-1" id="filepos178"></div>

<div class="calibre1" id="filepos17136">
<p class="calibre2"><a class="calibre8" href="../Text/Priestess_of_the_White_split_003.html#filepos989"> <span class="calibre3 bold calibre9">P</span><span class="calibre10 bold calibre9">ROLOGUE</span></a></p><br class="calibre4" />
<br class="calibre4" />

Last edited by lunixer; 07-24-2011 at 04:34 PM.
lunixer is offline   Reply With Quote
Old 07-24-2011, 07:19 PM   #6
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Do a search for <p class="calibre2"> to be sure that the only usage is in the Chapter Headers

Code:
Search: <p (class="calibre2">.+)</p>
Replace: <h3 \1<</h3>
then do a single section Search and Replace.
Press F7 to see if the TOC has that correct
Abort the edit if wrong.
change to All HTML and find next, Replace All
F7 to check

Anything that is wrong in the files should be looked at and edited back to <p ... </p>,
theducks is online now   Reply With Quote
Old 07-24-2011, 09:25 PM   #7
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by theducks View Post
Do a search for <p class="calibre2"> to be sure that the only usage is in the Chapter Headers

Code:
Search: <p (class="calibre2">.+)</p>
Replace: <h3 \1<</h3>
then do a single section Search and Replace.
Press F7 to see if the TOC has that correct
Abort the edit if wrong.
change to All HTML and find next, Replace All
F7 to check

Anything that is wrong in the files should be looked at and edited back to <p ... </p>,
Thanks for your ongoing help. Unfortunately, it didn't work. For example, in book mode and in the calibre reader, I get this:
Quote:
Replace:
<</h3>PROLOGUE
with this code:

Quote:
<h3 id="heading_id_2">&lt;&lt;/h3&gt;<a class="calibre8" href="../Text/Priestess_of_the_White_split_003.html#filepos989"> <span class="calibre3 bold calibre9">P</span><span class="calibre10 bold calibre9">ROLOGUE</span></a><br />
which was previously this:

Quote:

<div class="calibre1" id="filepos17136">
<p class="calibre2"><a class="calibre8" href="../Text/Priestess_of_the_White_split_003.html#filepos989"> <span class="calibre3 bold calibre9">P</span><span class="calibre10 bold calibre9">ROLOGUE</span></a></p><br class="calibre4" />
<br class="calibre4" />
Also, as question: assuming that we can get this fix working, will it work for all of the books that I have with this problem? I've figured out that I have at least eight books that need fixing because of this.

Anyway, thanks!
lunixer is offline   Reply With Quote
Old 07-24-2011, 11:40 PM   #8
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
I see the error there was an extra < in the replace code

it should be:
Replace: <h3 \1</h3>

The way this pattern works:
Search for any line starting with <p class="calibre2">
and ending with </p>
The stuff between the ( ) will be remembered, which will bring along any ID values.

the replace puts a <h3 in the spot that was the <p
that is followed by all the stuff remembered (the \1)
finally we want to end the line with a </h3> (not the <</h3> I stuttered)
theducks is online now   Reply With Quote
Old 07-26-2011, 07:25 PM   #9
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by theducks View Post
I see the error there was an extra < in the replace code

it should be:
Replace: <h3 \1</h3>

The way this pattern works:
Search for any line starting with <p class="calibre2">
and ending with </p>
The stuff between the ( ) will be remembered, which will bring along any ID values.

the replace puts a <h3 in the spot that was the <p
that is followed by all the stuff remembered (the \1)
finally we want to end the line with a </h3> (not the <</h3> I stuttered)
I'm not sure what I'm doing wrong, but I'm still not getting it. Now it says that your "find" pattern doesn't exist in the book. I've attached a screenshot showing my work in Sigil, if you would be willing to take a look and see if I'm doing this correctly. Thanks for the help!
Attached Thumbnails
Click image for larger version

Name:	Screenshot.png
Views:	88
Size:	206.3 KB
ID:	74840  
lunixer is offline   Reply With Quote
Old 07-26-2011, 08:05 PM   #10
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by lunixer View Post
I'm not sure what I'm doing wrong, but I'm still not getting it. Now it says that your "find" pattern doesn't exist in the book. I've attached a screenshot showing my work in Sigil, if you would be willing to take a look and see if I'm doing this correctly. Thanks for the help!
look close. you are missing the ( before the .+
because it was not a pair, it looked for something with a )</p> which is not there
Patterns are exacting
theducks is online now   Reply With Quote
Old 07-26-2011, 08:08 PM   #11
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by theducks View Post
look close. you are missing the ( before the .+
because it was not a pair, it looked for something with a )</p> which is not there
Patterns are exacting
Could you please type out exactly what should be in find? I copied/pasted the expression from your first post so I am unclear exactly what I should be using. Once again, thank you for the help.
lunixer is offline   Reply With Quote
Old 07-26-2011, 08:20 PM   #12
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by lunixer View Post
Could you please type out exactly what should be in find? I copied/pasted the expression from your first post so I am unclear exactly what I should be using. Once again, thank you for the help.
The original find I supplied is correct
Use the corrected replace

Last edited by theducks; 07-26-2011 at 08:25 PM.
theducks is online now   Reply With Quote
Old 07-26-2011, 08:22 PM   #13
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by theducks View Post
The original find I supplied is correct
Use the corrected replace
Code:
Search: <p (class="calibre2">.+)</p>
Replace: <h3 \1</h3>
I think I have removed all the typos

I cant see your code , is there a calibre2 in the chapter title

Last edited by theducks; 07-26-2011 at 08:26 PM.
theducks is online now   Reply With Quote
Old 07-27-2011, 05:35 PM   #14
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by theducks View Post
Code:
Search: <p (class="calibre2">.+)</p>
Replace: <h3 \1</h3>
I think I have removed all the typos

I cant see your code , is there a calibre2 in the chapter title
Still no luck with this pattern. This is what the code for a chapter header (chapter 1) looks like:

Code:
<body class="calibre" id="filepos178">
  <div class="calibre1" id="filepos50625">
    <p class="calibre2"><a class="calibre8" href="../Text/Priestess_of_the_White_split_003.html#filepos1441"><span class="calibre5 bold calibre9">1</span></a></p><br class="calibre4" />
    <br class="calibre4" />
lunixer is offline   Reply With Quote
Old 07-27-2011, 10:51 PM   #15
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 14,445
Karma: 5567061
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
I pasted your code into Sigil 3.4 and My terms into the S&R.
I then Searched. Verified what it found...
Then I clicked Replace
you can see the results
Attached Thumbnails
Click image for larger version

Name:	tocSnR.jpg
Views:	97
Size:	99.1 KB
ID:	74876  
theducks is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone tell me how to fix this? Downloaded wrong format? Aspen General Discussions 19 12-22-2010 05:55 PM
Calibre settings for using 'chapter' in TOC TargonD Calibre 13 11-03-2010 08:57 PM
ADE and long chapter names in ToC frabjous Reading and Management 3 08-14-2009 11:16 AM
Chapter or TOC Creation help needed gandor62 Calibre 4 04-15-2009 02:18 PM
html2epub TOC and chapter detection help ilovejedd Calibre 6 02-22-2009 05:58 PM


All times are GMT -4. The time now is 09:39 AM.


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