01-19-2011, 09:15 AM | #1 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jan 2011
Device: kindle 3
|
Find, replace, split chapter?
Hi all!
I'm very new to sigil, and even more so to regex.... so I'm really struggling to do something very simple. I want to find and replace all instances of chapter titles ie. "<p>Chapter 1</p>" etc with the same text, but set to H3, rather than regular sized text. Also, is it possible to use the find function to find the chapter titles and split it at that point into a new chapter? The file I have is a txt document, so it would be great to split it into chapters. Apologies for the noob questioning |
01-19-2011, 09:39 AM | #2 |
Wizard
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
with the tidy ( brush icon) active, this will work
find <p Chapter replace with <h2 Chapter ( so long as the word chapter does not also start a sentence anywhere - tidy will fix the trailing tag this is safer - find replace set to regex + match case, all files - in code view find <p Chapter ([\d+])</p> replace <h2 Chapter \1 </h2> the \d+ finds any number with 1 or more digits and the \1 in the replace syntax re-uses the value found in the find process. if find replace complains that there are no matches, check very carefully for superfluous whoops I see you wanted h3, not h2 - just amend the above examples it is a good idea to click replace ( once) a few times to check that it is working, before running replace all. variations of that syntax will fix up other types of chapter headings, but if you need to use a period ( a full stop) in regex you must place a backslash in front of it \. |
01-19-2011, 03:42 PM | #3 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jan 2011
Device: kindle 3
|
cybmole!
Thank you so much for the info. I'll give that a shot now and see how I get on. I had a look at a regex tutorial, but felt so overwhelmed by it. Hopefully I'll get the hang of it Thanks again! |
01-19-2011, 04:50 PM | #4 |
Guru
Posts: 655
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
Do a search for
Code:
<p>Chapter ([\d+])</p> replace Code:
<hr class="sigilChapterBreak" /><h3>Chapter \1</h3> <hr class="sigilChapterBreak" /> if it's at the beginning of the whole text. (i.e. there's no preface/prologue/contents etc.) You can then use the Sigil feature 'Tools>Split on SGF chapter markers' (F6) to split all those chapters into their own chapter files. |
01-19-2011, 09:01 PM | #5 |
Evangelist
Posts: 490
Karma: 1665031
Join Date: Nov 2010
Location: Vancouver Island, Nanaimo
Device: K2 (retired), Kobo Touch (passed to the wife), KGlo, Galaxy TabPro
|
a bit easier way...
Find: <p>(Chapter \d)</p> Replace <h3>\1</h3> Once your chapters are all done, just search for all the <h3> tags, move the blank line above and hit Ch break. |
01-19-2011, 09:53 PM | #6 | |
Well trained by Cats
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Roman Numerals are really fun to S+R Also note that Forward, Prelude,Epilogue will need attention. |
|
01-20-2011, 03:22 AM | #7 |
Wizard
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
roman numbers are easy!
the basic search set is [IVX]+ add, L, M if you are approaching 50 or 100 but that is rare I've done a few books, with no problems. find <p>([IVX]</p> etc . you may need other stuff e.g. there could be a class="bold" bit -so inspect in code view. copy the 1st instance ( chapter I) and replace I with the search set |
01-20-2011, 04:35 AM | #8 |
frumious Bandersnatch
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
01-20-2011, 04:01 PM | #9 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jan 2011
Device: kindle 3
|
Guys, thanks so much for all the input!
I wasn't too sure if I'd even get a response for such a basic question, so I really do appreciate all the answers |
Tags |
chapter, find, replace, sigil, split |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find / replace | bremler | Sigil | 6 | 12-17-2010 03:26 PM |
CSS wacky p indent post-chapter split? | Hitch | Sigil | 0 | 06-17-2010 08:59 PM |
Error: Could not find reasonable point at which to split | MTR | Calibre | 7 | 10-09-2009 11:03 AM |
Could not find reasonable point at which to split | scgf | Calibre | 20 | 09-14-2009 01:19 PM |
Using Find/Replace with BD | Otter | Sony Reader | 7 | 02-28-2009 01:49 PM |