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 08-09-2010, 02:40 AM   #1
Sylver
Addict
Sylver began at the beginning.
 
Posts: 234
Karma: 40
Join Date: Apr 2010
Device: The Nook, iPad
how to add linkable chapters and notes for epub

I am sure it's asked and answered many times and it must be in the user guide or something, but forgive me I am attentional dyslexia, so can someone help give me a very quick answer as to how to add linkable chapters and notes in Calibre?

I am converting a txt file to epub: there are chapters in the txt file but I am not sure how to compile a linkable chapter list before the main content out of a pure text based txt file? Do I need to convert it to Word or HTML first? Second question is regarding the notes, say, if I have a note link on page 3 and paragraph 2 that has a number "1", once clicked, it will take me to the notes page at the end of each chapter or the whole book - I would like to have the note has a clickable number "1" on it also, so if I click the "1" on the note page, it will bring me back to page 3 (and paragraph 3 preferably, but not required, as bring back to page 3 is good enough).

Are these doable in Calibre for txt files? if both are doable, exactly how to do this? Many thanks.
Sylver is offline   Reply With Quote
Old 08-09-2010, 02:52 AM   #2
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: 8,775
Karma: 12516053
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by Sylver View Post
I am converting a txt file to epub: there are chapters in the txt file but I am not sure how to compile a linkable chapter list before the main content out of a pure text based txt file?
Check out the last tip under Convert TXT documents in the user manual.

Quote:
Process using markdown
calibre also supports running TXT input though a transformation preprocessor known as markdown. Markdown allows for basic formatting to be added to TXT documents, such as bold, italics, section headings, tables, lists, a Table of Contents, etc. Marking chapter headings with a leading # and setting the chapter XPath detection expression to “//h:h1” is the easiest way to have a proper table of contents generated from a TXT document. You can learn more about the markdown syntax at daringfireball.

Last edited by DoctorOhh; 08-09-2010 at 02:55 AM.
DoctorOhh is offline   Reply With Quote
 
Enthusiast
Old 08-09-2010, 08:48 AM   #3
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
Posts: 637
Karma: 436517
Join Date: Jul 2010
Location: UK
Device: PRS-300, PW2
Calibre works well with Markdown but the links in Markdown are really intended as simple links to web pages rather than as text reference notes. However, it can be done and I have attached an example to get you started.

The attached plain text document contains the necessary markdown and has 2 reference notes which link in both directions.

A ToC is also generated which ended up at the end of my ePub but you can move this with any ePub editor. Perhaps it would be useful to have a calibre option to specify where this ToC should go.

Full details of how to convert are in the document itself.

It's worth reading the full Markdown specification as I have used other elements within the document to produce a better ePub. This will also stop you falling into some Markdown 'traps', e.g. 4 leading spaces on a line!
Attached Files
File Type: txt TxtLnk.txt (1.6 KB, 316 views)

Last edited by Agama; 08-09-2010 at 08:57 AM.
Agama is offline   Reply With Quote
Old 08-09-2010, 09:20 AM   #4
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,701
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
Quote:
Originally Posted by Agama View Post
A ToC is also generated which ended up at the end of my ePub but you can move this with any ePub editor. Perhaps it would be useful to have a calibre option to specify where this ToC should go.
@Agama, This option already exists just put the following, on a line of its own, in the TXT file at the point where you want the TOC to appear.
Code:
///Table of Contents///
If you don't include the line I think the TOC defaults to the end of the epub.
jackie_w is offline   Reply With Quote
Old 08-09-2010, 09:36 AM   #5
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
Posts: 637
Karma: 436517
Join Date: Jul 2010
Location: UK
Device: PRS-300, PW2
Quote:
Originally Posted by jackie_w View Post
@Agama, This option already exists just put the following, on a line of its own, in the TXT file at the point where you want the TOC to appear.

///Table of Contents///
Thanks for the info, this is useful to know.
Agama is offline   Reply With Quote
Old 08-09-2010, 09:39 AM   #6
Sylver
Addict
Sylver began at the beginning.
 
Posts: 234
Karma: 40
Join Date: Apr 2010
Device: The Nook, iPad
Thanks to all of you that replied, especially to Agama that provided the exact examples that I am asking for. Can't wait to give it a try. I forgot to mention that my source txt file is in Chinese, though I doubt there would be any difference (as there is no "#" and alphanumeric characters in Chinese so I don't expect there will be any issue). Will report after I tried.
Sylver is offline   Reply With Quote
Old 08-09-2010, 10:16 AM   #7
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
Posts: 637
Karma: 436517
Join Date: Jul 2010
Location: UK
Device: PRS-300, PW2
The "#" characters are important as they indicate an anchor within the current page in HTML. The rest of the link id is up to you. I used "n" prefix to link to a note, and "r" prefix to return from a note.

I have now attached the ePub which results from conversion.

You may well want to style your link references to make them look better, e.g. superscripts or within brackets, but be careful not to clash with Markdown.
Attached Files
File Type: epub TxtLnk.epub (5.8 KB, 141 views)

Last edited by Agama; 08-09-2010 at 10:19 AM.
Agama is offline   Reply With Quote
Old 08-09-2010, 11:26 AM   #8
Sylver
Addict
Sylver began at the beginning.
 
Posts: 234
Karma: 40
Join Date: Apr 2010
Device: The Nook, iPad
Thanks, Agama, your example works fine. However, mine does not. The issues is my txt file is in Chinese and should be in unicode. If I keep the txt in unicode, the resulting Chinese characters show properly, the chapter links work fine, however the notes link does not, it always point to the first page of the document. If I check Translate unicode characters to ASCII, both the chapter and notes links work fine, but the text is unreadable. In either case, my "///Table of Contents///" does not put the TOC on the place I specified (it did put the TOC at the right place if the text is English).
Sylver is offline   Reply With Quote
Old 08-09-2010, 11:48 AM   #9
suecsi
Rock Chick
suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.suecsi is fluent in JavaScript as well as Klingon.
 
suecsi's Avatar
 
Posts: 427
Karma: 4965
Join Date: May 2009
Location: near Heathrow
Device: Kindle 2i, Kindle DX, Kindle 3G
Agama

Thanks for this, it's really useful. I have some books that didn't work well from PDF that I have resorted to saving to text, but I am used to working with Wikis so this style of markup makes sense. Does it do the same thing if you convert a txt file to mobi?
suecsi is offline   Reply With Quote
Old 08-09-2010, 02:24 PM   #10
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
Posts: 637
Karma: 436517
Join Date: Jul 2010
Location: UK
Device: PRS-300, PW2
Quote:
Originally Posted by suecsi View Post

Does it do the same thing if you convert a txt file to mobi?
I don't know mobi format at all as I only use epub but markdown generates html which I guess becomes the input for calibre conversion. So if html to mobi works then I would expect markdown text to mobi to work the same way as for epub.
Agama is offline   Reply With Quote
Old 08-09-2010, 02:33 PM   #11
Agama
Guru
Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.Agama ought to be getting tired of karma fortunes by now.
 
Agama's Avatar
 
Posts: 637
Karma: 436517
Join Date: Jul 2010
Location: UK
Device: PRS-300, PW2
Quote:
Originally Posted by Sylver View Post
If I keep the txt in unicode, the resulting Chinese characters show properly, the chapter links work fine, however the notes link does not, it always point to the first page of the document.
I'm not sure that unicode is to blame here as it's possible to code html files in unicode, (presumably with Chinese characters). The output from Markdown processing is html so it may be worth more investigation. Perhaps the intermediate html files, (use calibre's debug mode), may shed some light on this problem.
Agama is offline   Reply With Quote
Old 08-09-2010, 02:46 PM   #12
pollito pito
i warned you ...
pollito pito doesn't litterpollito pito doesn't litterpollito pito doesn't litter
 
pollito pito's Avatar
 
Posts: 54
Karma: 222
Join Date: Apr 2010
Device: none
You can test online your Markdown experiments here:

http://daringfireball.net/projects/markdown/dingus

or here

http://markdownr.com/
pollito pito is offline   Reply With Quote
Old 08-09-2010, 07:14 PM   #13
Sylver
Addict
Sylver began at the beginning.
 
Posts: 234
Karma: 40
Join Date: Apr 2010
Device: The Nook, iPad
Quote:
Originally Posted by Agama View Post
I'm not sure that unicode is to blame here as it's possible to code html files in unicode, (presumably with Chinese characters). The output from Markdown processing is html so it may be worth more investigation. Perhaps the intermediate html files, (use calibre's debug mode), may shed some light on this problem.
Thanks, Agama, you are right it's not the unicode as I thought. It turns out to be the issue with the paragraph spaces. now I can duplicate same issue with your script also - on the TXT Input tab of Calibre, if I check the Preserve Spaces option, the same thing will happen: the TOC will be like literally "///Table of Contents///" and not a real hyper linked content list, the notes link will take you to the first page no matter it's the notes link in the text or the reverse link in the notes section. If I uncheck that "Preserve Spaces", both the TOC and notes links are working fine, however, the indent for each paragraph is too much (about 4 Chinese characters) - in my original txt file each paragraph has a 2 character indent, that is why I chose the "Preserve Spaces" option to render each paragraph to be indented by only 2 spaces - however this breaks the notes link for some reason I don't quite understand. I will live with these 4 character ugly indent for the paragraph for now as at least all the links work fine, it just doesn't look too good but it works. Thanks again.
Sylver is offline   Reply With Quote
Old 08-09-2010, 08:14 PM   #14
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 2,701
Karma: 3818505
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"
@Sylver,

Does it have any effect if you put something in the Convert|Look&Feel|ExtraCSS box along the lines of:

p {text-indent:1.5em}

If it makes a difference to the paragraph indent in the epub then you can adjust the 1.5em up or down to suit.
jackie_w is offline   Reply With Quote
Old 08-09-2010, 08:38 PM   #15
Sylver
Addict
Sylver began at the beginning.
 
Posts: 234
Karma: 40
Join Date: Apr 2010
Device: The Nook, iPad
Quote:
Originally Posted by jackie_w View Post
@Sylver,

Does it have any effect if you put something in the Convert|Look&Feel|ExtraCSS box along the lines of:

p {text-indent:1.5em}

If it makes a difference to the paragraph indent in the epub then you can adjust the 1.5em up or down to suit.
Thanks, Jackie_w. Yes, there is a check box on that tab (cannot remember what it's called) that will enable a dropdown on the right side where you can specify the indent (the default is 1.5em). I checked that one and took the default 1.5em and it looked good. I will need to find a way to remove all the two spaces hardcoded in my original txt file. But aside from that, most things now work properly. The TOC is now also working, the only thing is with "///Table of Contents///" it generates the TOC with a literal title "Table of Contents", I wish I could change that literal to something else, that currently is the only English text in a Chinese language book and looks odd.
Sylver 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
[Old Thread] calibre detects chapters, doesn't add to TOC Corey.Langner Calibre 17 09-25-2011 07:22 PM
Order of Chapters in HTML->ePub alias_neo Calibre 9 05-16-2011 11:55 AM
Hacks Is there a way to add multible chapters to make one book 18Coaster Amazon Kindle 4 09-10-2010 07:40 PM
RTF to ePub, Chapters Daddy Warpig Calibre 6 05-11-2010 11:06 PM
ePub Chapters vs. Stanza Chapters kjk Sigil 4 09-14-2009 10:50 AM


All times are GMT -4. The time now is 12:48 PM.


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