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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-25-2014, 02: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, 07: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,086
Karma: 1444487
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, 09:19 AM   #3
arspr
None
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: 491
Karma: 599350
Join Date: Mar 2011
Location: Madrid, Spain
Device: Sony PRS-650 >>> Kobo Aura HD (self-destructed) >>> Kobo Aura H2O
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, 11: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, 08: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,086
Karma: 1444487
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 08:41 PM.


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