![]() |
#1 |
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 18
Karma: 463230
Join Date: Apr 2010
Device: Kobo, Nexus 7
|
![]()
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? |
![]() |
![]() |
![]() |
#2 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
|
![]() |
![]() |
![]() |
#4 |
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
#5 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
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 |