Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 01-19-2011, 09:15 AM   #1
laelaps
Junior Member
laelaps began at the beginning.
 
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
laelaps is offline   Reply With Quote
Old 01-19-2011, 09:39 AM   #2
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
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 \.
cybmole is offline   Reply With Quote
Old 01-19-2011, 03:42 PM   #3
laelaps
Junior Member
laelaps began at the beginning.
 
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!
laelaps is offline   Reply With Quote
Old 01-19-2011, 04:50 PM   #4
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
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>
(as cybmole showed)

replace
Code:
<hr class="sigilChapterBreak" /><h3>Chapter \1</h3>
then after the replace, go back to top and remove the first
<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.
Perkin is offline   Reply With Quote
Old 01-19-2011, 09:01 PM   #5
Danger
Evangelist
Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.Danger ought to be getting tired of karma fortunes by now.
 
Danger's Avatar
 
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.
Danger is offline   Reply With Quote
Old 01-19-2011, 09:53 PM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
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:
Originally Posted by Danger View Post
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.
Make that a \d+ or you will only change the first 9 chapters.

Roman Numerals are really fun to S+R
Also note that Forward, Prelude,Epilogue will need attention.
theducks is offline   Reply With Quote
Old 01-20-2011, 03:22 AM   #7
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
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
cybmole is offline   Reply With Quote
Old 01-20-2011, 04:35 AM   #8
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by cybmole View Post
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'd add C and D earlier than M
Jellby is offline   Reply With Quote
Old 01-20-2011, 04:01 PM   #9
laelaps
Junior Member
laelaps began at the beginning.
 
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
laelaps is offline   Reply With Quote
Reply

Tags
chapter, find, replace, sigil, split


Forum Jump

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


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


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