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 06-15-2011, 06:25 AM   #1
madeinlisboa
Enjoy Life
madeinlisboa began at the beginning.
 
Posts: 26
Karma: 10
Join Date: Jun 2011
Location: Portugal
Device: Kindle
Structure detection on simple chapters

Hi,
i'm very confortable with regexps, but I can't make the structure detection work with these very simple chapters headers:

Code:
Chapter 1.<br>
I tried to drill down to the simplest code, but it just doesn't work:

Code:
//*[re:test(., "(Chapter|Book|Section|Part|Prologue|Epilogue)\s", "")]
Plase, help me.
madeinlisboa is offline   Reply With Quote
Old 06-15-2011, 06:45 AM   #2
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
It doesn't look like Chapter is in a tag. It needs to be in a tag to be work properly.
user_none is offline   Reply With Quote
Advert
Old 06-15-2011, 06:57 AM   #3
madeinlisboa
Enjoy Life
madeinlisboa began at the beginning.
 
Posts: 26
Karma: 10
Join Date: Jun 2011
Location: Portugal
Device: Kindle
OK, thanks. I thought that by indicating a pattern, Calibre could parse the chapter. Like /Chapter \d+\.\<br\>/
madeinlisboa is offline   Reply With Quote
Old 06-15-2011, 07:00 AM   #4
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
It can match a pattern but once it finds the match it references it to the current tag. Since it's XHTML references for links must point to a tag. So if your chapters are not in separate tags every one will match the same tag (duplicates are removed) and if I remember correctly it won't reference the body tag. So you get nothing.
user_none is offline   Reply With Quote
Old 06-20-2011, 05:29 AM   #5
madeinlisboa
Enjoy Life
madeinlisboa began at the beginning.
 
Posts: 26
Karma: 10
Join Date: Jun 2011
Location: Portugal
Device: Kindle
I found a great solution and I would like to share. Fortunately the search/replace is done before the chapter detection, so all you have to do is search eg.
Code:
Chapter\s*(\d+)
and replace with eg.
Code:
<h2>Chapter \1</h2>
. This way the chapters are properly found and converted.
madeinlisboa is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure Detection Problems Jonnster Conversion 21 05-12-2011 02:12 PM
structure detection - documentation ? cybmole Calibre 27 01-12-2011 02:14 AM
Trouble w structure detection jeff47 Calibre 1 10-13-2010 12:51 AM
Structure Detection Ceased To Exist? radiofred Calibre 3 10-01-2010 12:33 AM
Structure detection v5.5 and v6.2 AlexBell Calibre 2 07-29-2009 10:11 PM


All times are GMT -4. The time now is 07:29 PM.


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