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 02-25-2018, 01:57 PM   #1
MarjaE
Guru
MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.
 
Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
Making Epubs and Mobis Navigable?

I've converted some txt files to epub and mobi files. I've edited them to recreate chapter breaks.

Is there any way to add the table of contents and fix the navigation, so it's easy to flip to the next chapter?
MarjaE is offline   Reply With Quote
Old 02-25-2018, 02:23 PM   #2
sjfan
Addict
sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.
 
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
Quote:
Originally Posted by MarjaE View Post
I've converted some txt files to epub and mobi files. I've edited them to recreate chapter breaks.

Is there any way to add the table of contents and fix the navigation, so it's easy to flip to the next chapter?
If you've listed things in the opf correctly (html files under manifest, and then listed in the right order under spine) then you should flip to the next chapter automatically.

But your editor should do this for you by default, unless you're creating them by hand (which is a bad idea if you're not 100% sure what you're doing). Both Sigil and Calibre are free and work on most major platforms (including but not limited to Windows, Mac, and Linux). Sigil is an epub editor, Calibre is a whole ebook management solution (including conversion from epub to mobi with navigation+TOC once you're done editing) that includes an epub editor among many other things.

In both Calibre's editor and in Sigil, it's Tools->Table of Contents->Edit Table of Contents to edit the TOC.

If you used h1/h2/h3 etc for chapter headings then you can auto-generate a TOC. In Sigil there's a separate “Generate Table of Contents” entry in the same menu; in Calibre once you're in the TOC editor there's an option to auto-generate the TOC from major headings.

If you're editing by hand, you need a toc="blah" attribute on the spine tag in the opf, where blah is the id of an NCX file listed in the manifest. If you didn't already know that, though, you should probably use an editor. If you insist, the NCX format is discussed on the wiki.
sjfan is offline   Reply With Quote
Old 02-26-2018, 06:08 AM   #3
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Quote:
Originally Posted by MarjaE View Post
I've converted some txt files to epub and mobi files. I've edited them to recreate chapter breaks.
Depending on how you did it. You can use xpath for generating chapters. You only need to tell xpath how to identify your chapter marks.
In case you have structured text files (mark-down text files) you can use this as well in a conversion to generate capter and toc entries.
Divingduck is offline   Reply With Quote
Old 02-26-2018, 08:50 AM   #4
MarjaE
Guru
MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.
 
Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
I'm using Calibre to convert plain txt to epub and later mobi. Whatever opf is, Calibre hasn't set it up, or hasn't set it up in a way that helps my e-readers navigate the resulting pub files. Calibre hasn't been able to recognize the original chapter breaks either-- I have to manually merge and split sections in the epub editor afterwards.

Last edited by MarjaE; 02-26-2018 at 08:55 AM.
MarjaE is offline   Reply With Quote
Old 02-26-2018, 12:03 PM   #5
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Here are some easy and detailed instructions:

In your text file, add ## above each chapter heading and above any other section that you want to be in a separate html file after conversion. Calibre conversion will place each section below the ## into a separate html file, so when you create the ToC, you can choose "Generate ToC from Files."

Before converting the text file, change the following in the settings for Conversion -> Input Options -> TXT Input -> Structure:

Paragraph style - auto
Formatting style - markdown


If you don't want to do the above steps, then you can use "chapter" for the chapter class (or any other name you'd like), and when generating the ToC, choose "Generate ToC from XPath," and in the "Level 1 ToC" line in the following screen, enter one of the following (I have it in a ctrl-T macro):

If you use <p class="chapter">, enter the following:

//*[re:test(@class, "chapter", "i")]


If you use <h1 class="chapter">, enter the following:

//h:h1[re:test(@class, "chapter", "i")]

(Replace "chapter" with whatever name you used for the Chapter class.)

The above strings are generated after you click on the wand at the right and enter in h1, class, chapter or p, class, chapter, or whatever you use. If you save one of the above in a macro, you can just hit the macro hotkey to enter the string whenever you need it.

Last edited by deback; 02-26-2018 at 12:06 PM.
deback is offline   Reply With Quote
Old 02-27-2018, 06:21 AM   #6
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
@MarjaE,
the point is that this is not part of an one click solution. You need, as @deback pointed out, to tell calibre how it can find marks for possible chapter identifications. At least it needs something for identifying. It can be everything, from a format like a bold marked chapter line or a part of text, up to what ever you like to add to an existing text, e.g. as deback explained with adding "xx" or an identification like "Chapter bla bla bla" where you can use the beginning word "Chapter" as keyword for a Xpath construct within a TOC generation (as it is as part of the default set up for chapter detection). You can use those as part of the conversion process, afterwards with the TOC plugin or within the editor. These are some ways you can go for it.

There are more ways you can use depending on the source file you have. I had some months ago a huge document where in a fist view was no direct way to identify chapter headlines (no numbers, no key words and no real formats or special characters). In the end I recognize that chapter headline was introduce by a couple of line breaks followed by the chapter headline with once more some line breaks. I use this behavior for a post processing via S&R within the conversion to identify and for adding a unique chapter keyword to a chapter text what I then use for creating a TOC. All in one conversion including some general clean ups with S&R. A nice thing doing it that way is, that you can easily test the results and modify your manipulations to get a most possible clean document in a first step as you can stack these S&R actions and save and export/import them for future usage

Looking for "unique regularities". This is what helped me a lot doing this kind of stuff more efficient.

In addition to deback's explaination use the wizard for generating a valid xpath coding. It is easy to use and help a lot for learning and understanding. I made in the beginning lots of formal errors what prevent me some time for using Xpath. There is no real reason making this kind experiences too
The combination Xpath and S&R within the conversion process is handy and powerful for generating a good working basis for further fine tuning. At least for me
Divingduck is offline   Reply With Quote
Old 03-04-2018, 05:35 PM   #7
MarjaE
Guru
MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.
 
Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
I tried setting Calibre to use Markdown when importing from txt and marking each chapter with ##. It didn't do anything.

I haven't encountered any wizards. I think they're a Windows thing?
MarjaE is offline   Reply With Quote
Old 03-04-2018, 05:55 PM   #8
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
The wizard he talked about is the little box at the far right (with a wand in the box) after you click on Generate ToC from XPath. I gave you the actual string you can use, though, so you don't have to click on the wand.

After you entered ## (not "xx" as stated by Divingduck) above each chapter heading, did you save the .txt file, then drag the .txt file into Calibre, and then convert it to .epub (with markdown chosen, as I said above)? This will work to have the conversion process create a separate html file for each chapter or each section where you have ## at the top of each section. So, you must have done something wrong. Please read my instructions again, because it works.
deback is offline   Reply With Quote
Old 03-04-2018, 07:47 PM   #9
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Attached you will find an example with a text file and some pictures with settings.
Attached Thumbnails
Click image for larger version

Name:	calconvtxt##chaptermark2.PNG
Views:	199
Size:	68.9 KB
ID:	162638   Click image for larger version

Name:	calconvtxt##chaptermark4.PNG
Views:	211
Size:	59.2 KB
ID:	162639  
Attached Files
File Type: zip Sample XPath - DivingDuck.zip (782.4 KB, 164 views)
Divingduck is offline   Reply With Quote
Old 03-04-2018, 08:14 PM   #10
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Quote:
Originally Posted by Divingduck View Post
Attached you will find an example with a text file and some pictures with settings.
No, absolutely not! Neither image is what I was talking about and neither image will result in achieving what the original poster wants to do.


I'll try this again with an example:

In your .txt file, do the following (add ## above each section, which is usually above each chapter heading, above the title page, above the copyright page, above the dedication page, etc):


##

Chapter 1

This is the first line of chapter one.

##

Chapter 2

This is the first line of chapter two.

##

Chapter 3

This is the first line of chapter three.

##

About the Author

and so forth....

Save the .txt file.

Add the .txt file to Calibre. Or you can just drag the .txt file into Calibre from the folder where you saved it at.


In the Calibre conversion settings, choose "auto" on the top line and choose "markdown" on the second line, like I said in my first post in this thread. I'll repeat those instructions here:

Before converting the text file, change the following in the settings for Conversion -> Input Options -> TXT Input -> Structure:

Paragraph style - auto
Formatting style - markdown

After you have chosen the above settings in the Calibre conversion settings, run the conversion. The resulting .epub file should have separate .html files for each section that had ## at the top of each section.

Reread my original instructions for what to do after this is accomplished.
deback is offline   Reply With Quote
Old 03-04-2018, 08:29 PM   #11
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
Posts: 13,524
Karma: 78910202
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
Are you sure about the markdown code you've posted?

I believe it's either
Code:
## Chapter 1

This is the first line of chapter one.

## Chapter 2

This is the first line of chapter two.

## Chapter 3

This is the first line of chapter three.

## About the Author
OR
Code:
Chapter 1
-----------
This is the first line of chapter one.

Chapter 2
-----------
This is the first line of chapter two.

Chapter 3
-----------
This is the first line of chapter three.

About the Author
-------------------
In either case things will be mapped to h2's. For h1's usw a single # or an = sign.
PeterT is offline   Reply With Quote
Old 03-04-2018, 08:45 PM   #12
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Yes, I'm sure. I just opened one of the .txt files I edited back in 2015 (when I did a bunch of these), and the ## is above the section heading, like this (it doesn't matter if there's a line space after the ## or not):

##
Chapter 1

blah, blah

I'm not sure if it will work if you enter the ## on the left of the section heading or not. I would have to experiment to see if it will work, and right now, I have no interest in doing any experiments.

Also, I've never heard of using dashes (or underlines?) under the section headings, so I can't tell you if this will work or not without testing it.

Each ## tells Calibre conversion to place everything below the ## into a separate html file. The ## will not be included in the converted file.

Last edited by deback; 03-04-2018 at 08:54 PM.
deback is offline   Reply With Quote
Old 03-04-2018, 08:54 PM   #13
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
https://sourceforge.net/p/calibre/wiki/markdown_syntax/

Search for ## to find the section about how many #s to use for the desired sizes of the text (h1, h2, h3, etc).

No, I don't think it matters if the # or ## or ### are above or at the left of the section or chapter headings. You might not even have any section headings, so it doesn't matter.
deback is offline   Reply With Quote
Old 03-05-2018, 04:27 AM   #14
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
@deback,
only one thing. Stop saying my example isn't working. My example for @MarjaE is doing exactly what it is supposed to do.
Divingduck is offline   Reply With Quote
Old 03-05-2018, 07:28 AM   #15
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
You have ## on the third line in the wizard, but that line is for the class name, such as, chapter. The ## symbols are to be entered into the .txt file for each section (before the .txt file is converted to .epub), and then the ## symbols will not be in the converted epub file.

The things that are entered in the wand wizard are like this:

top line - p or h1, etc
second line - class
third line - chapter (or whatever name is used for the chapter classes)

Then the resulting string created by the wizard is this (for p, class, chapter):

//*[re:test(@class, "chapter", "i")]


You also have "auto" in the second line in the TXT Input screen. It should be Markdown, if one is following the instructions I gave for creating chapters and sections in a .txt file (that is, in order to create separate html files in the converted epub file for each chapter and each section by adding ## at the beginning of each chapter and each section in the .txt file--and then converting the .txt file to .epub).
deback is offline   Reply With Quote
Reply

Tags
calibre, conversion, txt to epub, txt to mobi


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any downside to making REALLY short epubs? Gregg Bell Sigil 8 05-21-2017 08:59 AM
Sideloading epubs and mobis to the iPad under Linux davidnye Devices 2 06-01-2012 08:30 AM
Rudy Rucker on Making Epubs Snooty Baronet ePub 7 09-25-2011 01:35 AM
Making ePubs show cover image on Kobo. Vanguard3000 ePub 3 01-03-2011 02:11 PM
Making epubs for Stanza on Ipod Touch Quasar Calibre 2 04-08-2010 10:35 PM


All times are GMT -4. The time now is 02:01 PM.


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