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

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-01-2010, 12:15 AM   #1
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 238
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Talking can calibre creat a TOC by reading numerals as chapter marks

I have a rather long book in txt format and I don't want to go to the hassle of putting two # marks in from of each numbered chapter in order to use --markdown. I wonder if I could use xpath statement to detect numerals on a line by themselves as chapter marks. If so could someone tell me how to format them?
Thanks
P3aul (pronounced "Paul", the 3 is silent)
p3aul is offline   Reply With Quote
Old 10-01-2010, 12:26 AM   #2
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
Try enabling preprocessing under structure detection when you do the conversion. You'll also need to change the chapter detection xpath to look for \d+ instead of Chapter|Part, etc
ldolse is offline   Reply With Quote
Old 10-03-2010, 03:12 PM   #3
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 238
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Can you tell me the exact location in pref to do this?
Thanks,
Paul
p3aul is offline   Reply With Quote
Old 10-03-2010, 05:03 PM   #4
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80520
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
It's in the structure detection part of the conversion settings.
Manichean is offline   Reply With Quote
Old 10-03-2010, 10:49 PM   #5
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
You'll also need to change the chapter detection xpath. Change the default to this:
Code:
//h:h2[re:test(., "\d+", "i")]

Last edited by ldolse; 10-03-2010 at 10:53 PM.
ldolse is offline   Reply With Quote
Old 10-04-2010, 04:51 AM   #6
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80520
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by ldolse View Post
You'll also need to change the chapter detection xpath. Change the default to this:
Code:
//h:h2[re:test(., "\d+", "i")]
Now you confused me- doesn't that test for the presence of numerals inside an h2 tag pair?
Manichean is offline   Reply With Quote
Old 10-04-2010, 05:03 AM   #7
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
Quote:
Originally Posted by Manichean View Post
Now you confused me- doesn't that test for the presence of numerals inside an h2 tag pair?
That's exactly what it does. Preprocessing just wraps the numerals in h2 tags, it doesn't tell Calibre's chapter detection routines that those are actually chapters.

The default chapter detection xpath is:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part\s+', 'i')) or @class = 'chapter']
So that won't match numeric chapter headings. The book would get page breaks inserted at the H2 tags (based on the insert page breaks before default setting), so in an epub for example you would have one split file per chapter, but there would be no TOC.

You could just change one part of the xpath - 'chapter|book|section|part\s+' to '\d+' or '.*', but I used the xpath wizard, which spit out the xpath I posted previously.
ldolse is offline   Reply With Quote
Old 10-04-2010, 05:18 AM   #8
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80520
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by ldolse View Post
That's exactly what it does. Preprocessing just wraps the numerals in h2 tags, it doesn't tell Calibre's chapter detection routines that those are actually chapters.
Ah. I missed the preprocessing part when thinking about it.
Manichean is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
tips for research reading- notes/search/marks 1611mac General Discussions 6 07-13-2010 01:14 PM
Les Miserables - TOC / Chapter Flags? gshipley Amazon Kindle 1 09-28-2009 11:07 PM
ADE and long chapter names in ToC frabjous Reading and Management 3 08-14-2009 12:16 PM
Chapter or TOC Creation help needed gandor62 Calibre 4 04-15-2009 03:18 PM
html2epub TOC and chapter detection help ilovejedd Calibre 6 02-22-2009 06:58 PM


All times are GMT -4. The time now is 05:30 PM.


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