Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-25-2014, 01:57 AM   #1
Ozman
Member
Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.
 
Ozman's Avatar
 
Posts: 18
Karma: 463230
Join Date: Apr 2010
Device: Kobo, Nexus 7
Question Add h2 tag to chapter heading to make TOC

I have some old epubs without a TOC that have chapter headings marked as <p>. Each book has approximately 30 chapters, Chapter 1...Chapter 30. It is a drag to manually find each heading, add the h2 tag, and then generate a TOC. I would like to find a way of automating this process.
I tried using calibre to convert epub to epub with heuristic processing to add the tag but nothing happened.
Can I do a find and replace, maybe with regex, to achieve the desired result?
Ozman is offline   Reply With Quote
Old 08-25-2014, 06:51 AM   #2
mrmikel
Color me gone
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
Try this:

Find:<p>Chapter (.+?)</p>
Replace:<h2>Chapter \1<\h2>

Do this one at a time to make sure you don't pick up references to Chapter x in the text itself.
mrmikel is offline   Reply With Quote
Old 08-25-2014, 08:19 AM   #3
arspr
Dead account. Bye
arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.arspr ought to be getting tired of karma fortunes by now.
 
Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
Quote:
Originally Posted by mrmikel View Post
Try this:

Find:<p>Chapter (.+?)</p>
Replace:<h2>Chapter \1<\h2>

Do this one at a time to make sure you don't pick up references to Chapter x in the text itself.
If your chapters are just numbers this Find would be a little safer
<p>Chapter (\d+?)</p>
arspr is offline   Reply With Quote
Old 08-25-2014, 10:52 PM   #4
Ozman
Member
Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.Ozman ought to be getting tired of karma fortunes by now.
 
Ozman's Avatar
 
Posts: 18
Karma: 463230
Join Date: Apr 2010
Device: Kobo, Nexus 7
Many thanks for the replies. I will try out the suggestions. Also, I noticed that some of the epubs are in the form of Chapter One... Chapter Thirty. Grrrrr.
Ozman is offline   Reply With Quote
Old 08-26-2014, 07:00 AM   #5
mrmikel
Color me gone
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
My regex would still work for those, but as I said, do it find/replace, find/replace instead of replace all. It won't take more than a couple of minutes even for 30 chapters. Just match the Chapter case sensitive.
mrmikel is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with Sigil and chapter titles (Heading 2) AprilHare Sigil 18 02-05-2020 08:14 PM
TOC conversion with images as Chapter Heading cabpp Conversion 5 04-21-2014 06:36 PM
heading tag with sigil 0.7.4 bobcdy Sigil 3 01-12-2014 12:45 PM
How to avoid page break after heading/chapter tkirke ePub 6 01-22-2010 02:12 PM
Controlling chapter heading sizes? Djehuty Calibre 3 04-27-2009 08:02 PM


All times are GMT -4. The time now is 06:15 PM.


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