Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-24-2016, 08:30 PM   #1
morgon
Junior Member
morgon began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Sep 2015
Device: none
Help with chapter detection

Hi,

I try to convert a rtf to epub and would like calibre to detect the chapters by regex.

The chapters are easily identified by starting with the chapter number, then a dot, followed by the chapter name in captitals (apart from A-Z the only character appearing in chapter names is an apostrophe.

So I use this:

Code:
//*[re:test(., "^\d+\. [ 'A-Z]+$")]
And this works - all chapters are detected but the problem I am having is that each chapter is added to the TOC twice.

Why is that?

Can anybody suggest a solution so that each chapter only appears in the TOC once?

Many thanks!
morgon is offline   Reply With Quote
Old 03-24-2016, 10:30 PM   #2
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,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
do you already have an inline TOC?
theducks is offline   Reply With Quote
Advert
Old 03-25-2016, 11:14 PM   #3
morgon
Junior Member
morgon began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Sep 2015
Device: none
I managed to work around it by having a look at the debug-logs.

It seems that calibre converts input-files into an intermediate xhtml-format to which the xpath-selectors refer.

In my case I found that all the chapter-headings from the input-rtf where rendered as h1-tags, so I changed the selector to:

Quote:
//h:h1[re:test(., "^\d+\. [ 'A-Z]+$")]
And this works now. All chapters detected, only one entry in the TOC.

Unfortunately I still don't understand why the chapters appear twice with the above selector....

Oh well...
morgon is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Chapter detection ubergeeksov Calibre 0 09-02-2010 04:56 AM
xpath for chapter detection romnempire Calibre 7 07-26-2010 05:34 PM
chapter detection in any book yuki86 Calibre 9 05-06-2009 06:54 AM
Chapter detection for LRF HenryP Calibre 12 04-03-2009 08:22 AM
Cant find help for chapter detection fallwood Calibre 6 12-10-2008 01:20 PM


All times are GMT -4. The time now is 09:46 PM.


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