06-22-2010, 03:08 PM | #1 |
Enthusiast
Posts: 38
Karma: 608
Join Date: Aug 2009
Location: Toronto
Device: all devices
|
How does the TOC editor work?
I want to build a TOC for this .epub file and I can't figure out how to add to the table of contents. For some reason with this particular .epub file generated from InDesign, the TOC navigation wasn't automatically added in.
Can someone give me a hand in figuring out how to add stuff with Sigil to the TOC? Cheers, Luise |
06-22-2010, 03:49 PM | #2 |
Bookmaker & Cat Slave
Posts: 11,482
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
TOCs, Headers and other strangers
Oh, oh!! I know that one!
In Sigil, this is simplicity itself. For every Chapter Heading, e.g., if you have: "Chapter One" Just highlight the Chapter One text and select "Heading 1" from the drop-down list on the left-hand side of the menu box. For sub-chapters, if you have them, choose Heading 2, and so on. If you have an ACT structure--which I do for many clients--I use Heading 1 for the Acts (Act I, Act II, etc.) and Heading 2 for the Chapters. You can also do this in codeview, if you wish, in the html, which I actually how I do it, but everyone has their own way of working. You can also use a spiffy feature of Sigil that I particulary like and end up using surprisingly often--you can create a TOC item for something that does not have text, like an illustration, by inserting a header on the page (you have to do this in codeview), thusly: Code:
<h3 title="Illustration: Map of Disneyland"></h3> You can then view the TOC in the TOC editor. You can select items to omit by deselecting them (scroll to the right in the TOC editor where you'll see the checkmarks--uncheck anything you do not want to include). You can start out getting a feel for this by just doing one Chapter header, then look at the TOC Editor to see it building; it'll give you a good idea of what's going on and help you build your TOC. n.b.--you'll probably have to restyle your headers in your CSS, if you have not already included them in that file; be prepared for them to go wonky if the CSS isn't already there, so don't panic if they are suddenly Arial 14 or whatever. I hope that helped!! Hitch |
06-22-2010, 03:54 PM | #3 | |
Well trained by Cats
Posts: 30,364
Karma: 58053698
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Any H1, H2, H3 tagged items appear in the TOC. I tend to use H2 for multi part books and H3 for chapters. That way the TOC indent Code:
Book Title ... <h2>Part 6: Disaster Strikes </h2> <h3>Chapter 20: Flood </h3> <h3>Chapter 21: Pestilence</h3> ... |
|
06-22-2010, 04:10 PM | #4 |
Enthusiast
Posts: 38
Karma: 608
Join Date: Aug 2009
Location: Toronto
Device: all devices
|
Hmm...
So what if your .epub document was generated with automatic styles, and uses the following code: Code:
<p class="h1"> Heading 1</p> <p class="h2">Heading 2</p> <p class="tf">First paragraph without any indent</p> <p class="tx">Second paragraph, with indent.</p> with associated styles already generated... Last edited by Kivgaen; 06-22-2010 at 04:10 PM. Reason: spelling |
06-22-2010, 04:23 PM | #5 | |
Well trained by Cats
Posts: 30,364
Karma: 58053698
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
make a h.h1 class out of the p.h1 class and change the p tag pairs to h1 in your book (repeat for h2 and h3 ) |
|
06-22-2010, 04:28 PM | #6 | |
Created Sigil, FlightCrew
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
In general, I recommend reading the manual. There's a section for the TOC editor.
Quote:
Code:
<h1> Heading 1</h1> You could easily convert to this scheme with a regex search&replace operation. |
|
06-22-2010, 05:13 PM | #7 | |
Guru
Posts: 696
Karma: 150000
Join Date: Feb 2010
Device: none
|
Quote:
search for: <p class="h1"> (Heading\s\n+?)</p> replace with: <h2>\0</h2> where "\0" refers to whatever is in parenthesis in the search string. Note that sigil uses \1 for the first set of parentheses, and a checkbox for minimal search instead of the perl "?". My example uses the syntax of the bluefish html editor. Then, in the stylesheet, create a style for h2 that is a copy of the style specified by p.h1 (in this example. YMMV). If you've just replaced all of the <p class="h1"> tags, you can remove the p.h1 style from the stylesheet. While I'm at it, I do other cleanup tasks that are best done globally, like insert sigil chapter-break marks, etc. and then re-zip the original epub and feed it to sigil for breaking up into chapters and any final polishing needed. |
|
06-22-2010, 07:46 PM | #8 | |
Enthusiast
Posts: 38
Karma: 608
Join Date: Aug 2009
Location: Toronto
Device: all devices
|
Quote:
<p class="h1">1. The Other Minister</p> <p class="h1">2. Spinner's End</p> <p class="h1">3. Will and Won't</p> etc... Then I could do a global find and replace that would search for the first instance of <p class="h1">... and then grab all of the string between that and the closing </p> tag and plop it into the new <h1> tag? If that's what you're saying, that's perfect... |
|
06-22-2010, 08:43 PM | #9 | |
Guru
Posts: 696
Karma: 150000
Join Date: Feb 2010
Device: none
|
Quote:
Find what: <p class="h1">(.+)</p> and it means roughly this: "find a string that starts with <p class="h1">, followed by one or more of any character [that's the .+ part], followed by </p>. The parenthesis means "remember the part of the string that's represented by .+ -- that is, the "one or more characters" between the <p class="h1"> and the </p>." In general, you could have more than one set of parentheses. The contents of the first set gets assigned to the temporary variable \1, the second set to \2, and so on. You must also check the box "Minimal Matching" on the search dialog, and choose the "Regular expression" radio button, and the "down" button. If you don't check "minimal matching" the search string will match as big a string as possible, which would be from the first <p class="h1"> to the very last <p/> in the file, which you don't want in this case! If your head seems like it's ready to explode, don't worry. It probably won't. That's a normal reaction to the concept of regular expressions. You get used to it, supposedly. OK, now the fun part. the "Replace With:" string looks like this: <h1>\1</h1> which means that the <p class="h1"> gets replaced by <h1>, the </p> gets replaced with </h1>, and the contents of variable \1 (i.e. the actual text of the header) gets put in between. Voila. I strongly recommend you test your regular expression using just "find," not "replace," before you turn it loose. Sometimes that's the only way to be sure what a given regex will do. check out Zelda_Pinwheel's excellent thread on this topic. Lots of great information. It is here: https://www.mobileread.com/forums/showthread.php?t=75805 Phew, that's a long and detailed answer from someone who knows next to diddly about regex. If I've made a mess of things, I hope someone more knowledgeable (Y'all know who you are!) will come along and clean it up. |
|
06-22-2010, 09:29 PM | #10 | |
Not who you think I am...
Posts: 374
Karma: 30283
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
|
Quote:
Your explanation implies that because your search has three parts and your replacement has three parts, each part is being individually replaced. It's one blob being replaced by another blob that has a sub-blob being remembered from the first blob and inserted somewhere. Does that make sense? As a way of exampling, using your search example above, you could replace with \1 or MAD-SEARCHEZ!!1 or <h1></h1>\1 -- it's all one blob, replacing the blob that matched the search blob. The reason I stress this, it's really useful to change the order of things using multiple sub-matches, but you must be clear that the pattern is not implicit, it's an overt expression. June 14th, 2010, say, can become 14-June-2010 or 2010-June-14 or anything else pretty easily. e.g. Code:
Search: (.+) (\d\d)th (\d\d\d\d) Replace: \2-\1-\3 or Replace: \3-\1-\2 or Replace: Today is the \2th day of the month of \1 in the year \3. cap |
|
06-23-2010, 01:13 AM | #11 |
Bookmaker & Cat Slave
Posts: 11,482
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
cap:
You know her head just exploded, right? ;-) Hitch |
06-23-2010, 04:11 AM | #12 |
Not who you think I am...
Posts: 374
Karma: 30283
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
|
Too many blobs?
cap |
06-23-2010, 09:46 AM | #13 | |
Guru
Posts: 869
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Quote:
Find what: <p class="h1">([^<]+)</p> The only difference from a users point of view is that you are guaranteed that the regex will stop at the first < it comes across. .+ means search for 1 or more character, no matter what it is. [^<]+ means search for 1 or more of any character that is not '<' You would use the same replace term in either case - <h1>\1</h1> |
|
06-23-2010, 10:30 AM | #14 |
Enthusiast
Posts: 38
Karma: 608
Join Date: Aug 2009
Location: Toronto
Device: all devices
|
about blobs...
Thanks, that was all very well explained. (And no, my head didn't explode... although I agree, there may have been a few too many blobs.) I'm actually a mathematician, so the idea of expressions is old hat to me. You all explained it very well. Thanks for the link to that thread -- I'll check it out later if I need more assistance when I get started on my next book. Thanks for all the help (and the laughs). I can't wait to get to work today and try it out. (which reminds me... I'm late already!) |
06-23-2010, 11:36 AM | #15 |
Bookmaker & Cat Slave
Posts: 11,482
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Blob-A-Ran
And cap, just for you:
Blob-blob-blob, blob-blob-aran, Blob-blob-blob, blob-blob-aran Oh Blob-ar-ah-an, Come take my ha-a-nd.... Blob-ar-aaan, You got me cutting-and-a-pastin', searchin' and replacin' Blob-a-ran blob blob Blob blob-a-ran Went to a File, Looking for a Style, Saw Blab-a-ran, thought she'd go a mile, With Blob-a-ran, blob-a-ran Come Take my H-a-a-nd.... with big-time apologies to the Beach Boys. For those of you that like me, are nearly older than dirt. Hitch |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sigil Toc editor | Enesco | Sigil | 16 | 09-23-2010 06:41 AM |
PRS-500 Software: LRF TOC Editor v1.02 | hal9000 | Sony Reader Dev Corner | 29 | 07-04-2010 07:17 PM |
Problem with TOC editor | alecE | Sigil | 2 | 10-29-2009 01:30 AM |
Getting TOC to work? | enarchay | Sony Reader | 11 | 05-28-2009 05:46 AM |
Making a TOC for LRFs? Issues with Calibre + LRF TOC editor not working | Magitek | LRF | 0 | 05-06-2009 01:25 PM |