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

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 11-26-2012, 02:08 PM   #1
memenow
Junior Member
memenow began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2012
Device: nook
How to automatically create chapter titles and breaks in an epub file?

I have a big file that is separated into categories with an underscore beneath each category name. The file is constantly changing and there are 80 categories. It is a plain text file. I would like to make it so that each category name is a separate chapter in an epub file. I would also like to make sure each chapter name is the title of the chapter. Is there a way to do this automatically with Calibre? Maybe some regex magic? For example, I would like the chapter titles for the categories below to be: Fruit, Vegetables, Herbs. And I would like it to be parsed automatically (one way to do this would probably involve recognizing the underscores in a regex expression). How can I do this?


Fruit
________
Apples
Bananas

Vegetables
____________
Cucumbers
Zucchini

Herbs
_____
thyme
cayenne
memenow is offline   Reply With Quote
Old 11-26-2012, 04:35 PM   #2
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,895
Karma: 4632610
Join Date: Dec 2010
Device: Kindle PW2
Since your souce file is a text file, you could simply use Markdown to mark headings and convert the text file with Calibre to an ePub before editing it with Sigil.

(Select Convert books > TXT Input > Formatting Style: markdown before you convert the text file to an ePub file.)
Doitsu is offline   Reply With Quote
Old 12-06-2012, 02:01 PM   #3
mzmm
Groupie
mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.
 
mzmm's Avatar
 
Posts: 161
Karma: 86115
Join Date: Feb 2012
Device: iPad, Kindle Touch, Sony PRS-T1
bit late, but you could replace

(^\w+[^\n]+)(\s+(_)\3[^\n]+)

with

<h1>\1</h1>\2

and then generate the toc in sigil
mzmm is offline   Reply With Quote
Reply

Tags
calibre, epub, regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter Breaks in .txt file on Kindle? BKh Workshop 3 05-10-2012 09:39 AM
Create a valid EPUB file from PRC? lripperton ePub 2 01-16-2011 12:09 PM
reorgainse epub into 1 file per chapter cybmole Calibre 3 01-15-2011 07:24 AM
PRS-350 Breaks after Chapter Titles Rand Brittain Sony Reader 2 10-25-2010 12:53 PM
Automatically convert file to EPUB upon import into library astrodad Calibre 6 07-23-2010 12:22 PM


All times are GMT -4. The time now is 05:49 AM.


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