Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-30-2010, 09:01 PM   #1
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Exclamation Book, Part, Chapter

I use a txt file and convert that to epub. When I have a book title and chapter symbols I use # for the title, ##chapter using markdown everything works fine.

The problem occurs when I have a book broken down into parts and further broken down into chapters. I have tried using # for the title ## for the parts and ### for the chapters but it doesn't work. Calibre just doesn't seem to recognize the triple #'s. Can anyone help me?
TIA,
Paul
p3aul is offline   Reply With Quote
Old 03-30-2010, 09:25 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
That's strange. Can you attach a test case.
kovidgoyal is offline   Reply With Quote
Advert
Old 03-30-2010, 11:09 PM   #3
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Ok I have shortened the file to a couple of parts and the chapters to two or three.

I am using the latest version of Calibre .6.45. I am using the program itself to convert, selecting Markdown in Text input. As you can see, the parts are in the TOC because of ## but the chapters are missing. I used ### in front of the chapter headings
Attached Files
File Type: txt Test Case - Someone.txt (20.4 KB, 210 views)
File Type: epub Test Case - Someone.epub (137.2 KB, 233 views)
p3aul is offline   Reply With Quote
Old 03-31-2010, 12:29 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want page breaks before the ### elements you have to change the

insert page breaks before setting to

//*[name()='h1' or name()='h2' or name()='h3']
kovidgoyal is offline   Reply With Quote
Old 03-31-2010, 01:24 AM   #5
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
I just want the chapter names to show in the TOC. As it is only part names(the ones with##) are showing in the TOC I thought the hash marks would indicate to the parser that a ###Chapter is to be placed in the TOC below the Part name or number that begins with ##. That doesn't seem to be the case here.
p3aul is offline   Reply With Quote
Advert
Old 04-01-2010, 01:53 AM   #6
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
I was able to get the chapters but not the parts listed in the TOC in a RTF file by using //h3 in the preferences.

Well I guess this problem is so far down in the list it will never get solved sigh......
p3aul is offline   Reply With Quote
Old 04-01-2010, 02:18 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
What happens is the following:

# gets turned into h1

## gets turned into h2

### gets turned into h3

By default calibre creates a TOC base donly on h1 and h2

If you want to create one based on h3 as well, you have to explicitly tell it so, via the level 1/2/3 TOC options, as I outlined above
kovidgoyal is offline   Reply With Quote
Old 04-01-2010, 04:44 PM   #8
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Quote:
f you want to create one based on h3 as well, you have to explicitly tell it so, via the level 1/2/3 TOC options, as I outlined above
I did that Kovid, just as you said. In RTF I could get the h3 rendered as a chapter not in TXT though. This is what I had in mind:

Title rendered by h1 or #
Part one as h2 or ##
Chapter one as h3 or ###
Chapter Two as h3 or ###
Chapter Three as h3 or ###
Part Two as h2 or ##
Chapter One as h3 or ###
Chapter Two as h3 or ###
And so forth.


It may be that Calbre simply can't do this or that it was not written to do this. This is the way the TOC would appear in a paper book.

It also may be that it can be done with css?

Thanks,

Paul
p3aul is offline   Reply With Quote
Old 04-01-2010, 08:13 PM   #9
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
Let me preface this by saying I have never attempted this before.
Quote:
Originally Posted by kovidgoyal View Post
//*[name()='h1' or name()='h2' or name()='h3']
I took your Test Case text file, followed Kovid's suggestion as quoted above. To avoid confusion I attached an image of the settings I used.

Quote:
Originally Posted by p3aul View Post
This is what I had in mind:

Title rendered by h1 or #
Part one as h2 or ##
Chapter one as h3 or ###
Chapter Two as h3 or ###
Chapter Three as h3 or ###
Part Two as h2 or ##
Chapter One as h3 or ###
Chapter Two as h3 or ###
This seemed to create the TOC structure you want. It shows the h2 and h3 items. I might be missing something, check out the attached image of the TOC.

I also attached the ePub it created. Isn't this what you asked for?
Attached Thumbnails
Click image for larger version

Name:	Test Case.png
Views:	303
Size:	72.3 KB
ID:	49029   Click image for larger version

Name:	Structure_detection.png
Views:	276
Size:	5.8 KB
ID:	49030  
Attached Files
File Type: epub Test Case - Unknown.epub (137.5 KB, 237 views)

Last edited by DoctorOhh; 04-01-2010 at 08:16 PM.
DoctorOhh is offline   Reply With Quote
Old 04-01-2010, 10:42 PM   #10
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Yes that's exactly what I wanted. Why can't it work for me? Here is the setting I used, as cut and pasted into this post.

(1) This under "Detect Structure: Detect Chapters at(xpath expression)
//*[((name()='h1' or name()='h2' or name()='h3') and re:test(., 'chapter|book|section|part\s+', 'i')) or @class = 'chapter']
All I did was add "or name()='h3' to the default line.

(2) In "Table of Contents" I just added //h3

(3) in Text Input I checked "Use Markdown"

Isn't this the same as you and Kovid said was what to do?
p3aul is offline   Reply With Quote
Old 04-01-2010, 11:13 PM   #11
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
Quote:
Originally Posted by p3aul View Post
Yes that's exactly what I wanted. Why can't it work for me? Here is the setting I used, as cut and pasted into this post.

(1) This under "Detect Structure: Detect Chapters at(xpath expression)
//*[((name()='h1' or name()='h2' or name()='h3') and re:test(., 'chapter|book|section|part\s+', 'i')) or @class = 'chapter']
All I did was add "or name()='h3' to the default line.
He didn't say to add something to the default. He gave you a new string. That is why I included an image so you could see what I used.

Quote:
Originally Posted by p3aul View Post
(2) In "Table of Contents" I just added //h3
I didn't put anything in the "Table of Contents" area. I left it blank. Kovid said to do one thing, so that's what I did.

I thought I saw you say you didn't want pagebreaks so I did change that to none (see previous image).

Quote:
Originally Posted by p3aul View Post
(3) in Text Input I checked "Use Markdown"
I selected this too.

Quote:
Originally Posted by p3aul View Post
Isn't this the same as you and Kovid said was what to do?
No, but I hope you understand now.

I'm glad this solution does what you want.

Last edited by DoctorOhh; 04-01-2010 at 11:15 PM.
DoctorOhh is offline   Reply With Quote
Old 04-01-2010, 11:57 PM   #12
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 239
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
hi! thanks for answering so quickly and thanks for taking the trouble to troubleshoot my code. You know, when I was composing that last post, I looked back and saw that Kovid just had an abbreviated line of code and I wondered, but just thought he didn't want to put the whole thing there. I guess all that chapter stuff can't be there if you want the TOC to be hierarchical in form. I havn't tried it yet but I'm sure the solution is what you said. It sure makes sense.
Thanks,
Paul
p3aul is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpticBook 3600 Book Scanner Review - Part I Bob Russell Workshop 68 01-28-2011 09:17 AM
Removing part of a book :( Katdragon Sigil 3 07-10-2010 08:44 AM
MobiDeDRM removes part of the book?? highwaykind Kindle Formats 4 04-04-2010 02:26 PM
Only part of a Mobi book converting? AFK_Matrix Calibre 3 02-07-2010 07:57 PM
I need your help, users of e-book readers: Part 2... PEAL Which one should I buy? 1 08-03-2009 03:46 AM


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


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