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

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 08-03-2011, 02:57 PM   #1
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
Table of contents doesn't work for me

Thanks for this great forum.

I'm having trouble getting a table of contents when outputting a .mobi from an html file in Calibre. I've set a chapter style like this:

}
p.chapter
{
text-indent: 1em;
font-weight: bold;
font-size: 1.2em;
margin-top: 2em;
margin-bottom: 1em;
page-break-before: always;

and wrapped the chapter headings like this:

<p class="chapter">Body of Evidence</p>

The Structure Detection has this in its 'Detect chapters at (XPath expression):

//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\s+', 'i')) or @class = 'chapter']

In the Table of Contents icon's dialogue, I've left 'Force use of auto-generated Table of Contents' unchecked, and in its 'Level 1 TOC (XPath expression)' field I've added:

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

What am I doing wrong?

Thanks in advance for your help.
Tearin de Hairou is offline   Reply With Quote
Old 08-03-2011, 03:13 PM   #2
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
That obviously shouldn't be a smiley in the middle of that text, by the way, heh!
Tearin de Hairou is offline   Reply With Quote
Old 08-03-2011, 04:35 PM   #3
PeterT
Taking a break; Fed up
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.
 
PeterT's Avatar
 
Posts: 7,355
Karma: 46281507
Join Date: Nov 2007
Location: Toronto
Device: Wife: Touch, Arc, Vox Me: Nexus 7, Glo
Quote:
Originally Posted by Tearin de Hairou View Post
Thanks for this great forum.

I'm having trouble getting a table of contents when outputting a .mobi from an html file in Calibre. I've set a chapter style like this:

Code:
}
p.chapter
{
  text-indent: 1em;
  font-weight: bold;
  font-size: 1.2em;
  margin-top: 2em;
  margin-bottom: 1em;
  page-break-before: always;
and wrapped the chapter headings like this:

Code:
	 <p class="chapter">Body of Evidence</p>
The Structure Detection has this in its 'Detect chapters at (XPath expression):

Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\s+', 'i')) or @class = 'chapter']
In the Table of Contents icon's dialogue, I've left 'Force use of auto-generated Table of Contents' unchecked, and in its 'Level 1 TOC (XPath expression)' field I've added:

Code:
//h:p[re:test(@class, "chapter", "i")]
What am I doing wrong?

Thanks in advance for your help.
It helps to wrap stuff like that in [ CODE ] [ / CODE ] blocks.
PeterT is online now   Reply With Quote
Old 08-04-2011, 01:45 PM   #4
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
Sorry, Peter, wrap items like what? And where do the code and anti-code blocks go? And do they have angle brackets around them?

By the way, should Calibre be spitting out an NCX table of contents, to help readers navigate their way through the book? Apparently Amazon now demands this, and really they might as well be demanding that I give them a wheel that would spin straw into gold for all the hope I have of doing it.
Tearin de Hairou is offline   Reply With Quote
Old 08-04-2011, 02:02 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
Xpath isn't my strong suit, but it looks like it would have worked if you hadn't touched anything in the 'Table of Contents' section.

Basically this:
Code:
//h:p[re:test(@class, "chapter", "i")]
Is probably screwing up the default TOC xpath in the structure detection section, which should detect your chapter headings by default.

If you get the structure detection/TOC settings right Calibre will generate an NCX for you.
ldolse is offline   Reply With Quote
Old 08-04-2011, 02:12 PM   #6
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,906
Karma: 4329385
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, PB360, Kobo Glo/AuraHD/Aura6"/AuraH2O
What happens if you change this:
Quote:
Originally Posted by Tearin de Hairou View Post
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\s+', 'i')) or @class = 'chapter']
to this:
Quote:
Originally Posted by Tearin de Hairou View Post
Code:
//h:p[re:test(@class, "chapter", "i")]
in the Structure Detection - Detect chapters at box
jackie_w is offline   Reply With Quote
Old 08-04-2011, 02:53 PM   #7
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
No, I'd originally left it alone and got no table of contents at all.

By the way, I've another weird problem: the paragraphs have a couple of acres with them when the book is made. I've looked at other ebooks, for instance The Hunger Games, and this isn't the case with them. How on earth do I fix this?

Edit: I tried again to use the menu at those fields and return to the original //*[((name.... stuff (catchy!) but on outputting the file got an error message saying "Failed: Convert book 1 of 1 (Attempt at an Aardvark)" (Attempt at an Aardvark being the title of the book).

This dialogue had a button 'Show details'; I used 'copy to clipboard' on this and got:

Spoiler:

calibre, version 0.8.12
ERROR: Conversion Error: <b>Failed</b>: Convert book 1 of 1 (Attempt at an Aardvark)

Convert book 1 of 1 (Attempt at an Aardvark)
Processing archive...
Resolved conversion options
calibre version: 0.8.12
{'asciiize': False,
'author_sort': None,
'authors': None,
'base_font_size': 0.0,
'book_producer': None,
'breadth_first': False,
'change_justification': u'original',
'chapter': u"//*[((name()='h1' or named()='chapter' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\\s+', 'i')) or @class = 'chapter']",
'chapter_mark': u'none',
'comments': None,
'cover': u'/var/folders/4l/7q0n1hkn7y3dg76kps5m360m0000gn/T/calibre_0.8.12_tmp_q4Glu5/calibre_0.8.12_OmCgHm.jpeg',
'debug_pipeline': None,
'dehyphenate': True,
'delete_blank_paragraphs': True,
'disable_font_rescaling': False,
'dont_compress': False,
'dont_package': False,
'duplicate_links_in_toc': False,
'enable_heuristics': False,
'extra_css': None,
'fix_indents': True,
'font_size_mapping': None,
'format_scene_breaks': True,
'html_unwrap_factor': 0.4,
'input_encoding': None,
'input_profile': <calibre.customize.profiles.InputProfile object at 0x108739410>,
'insert_blank_line': False,
'insert_blank_line_size': 0.5,
'insert_metadata': False,
'isbn': None,
'italicize_common_cases': True,
'keep_ligatures': False,
'kindlegen': False,
'language': None,
'level1_toc': u'//h[re:test(@class, "chapter", "i")]',
'level2_toc': None,
'level3_toc': None,
'line_height': 0.0,
'linearize_tables': False,
'margin_bottom': 5.0,
'margin_left': 5.0,
'margin_right': 5.0,
'margin_top': 5.0,
'markup_chapter_headings': True,
'max_levels': 5,
'max_toc_links': 50,
'minimum_line_height': 120.0,
'mobi_ignore_margins': False,
'mobi_toc_at_start': True,
'no_chapters_in_toc': False,
'no_inline_navbars': True,
'no_inline_toc': False,
'output_profile': <calibre.customize.profiles.KindleOutput object at 0x108739a50>,
'page_breaks_before': u"//*[name()='h1' or name()='h2']",
'personal_doc': u'[PDOC]',
'prefer_author_sort': False,
'prefer_metadata_cover': False,
'pretty_print': False,
'pubdate': None,
'publisher': None,
'rating': None,
'read_metadata_from_opf': u'/var/folders/4l/7q0n1hkn7y3dg76kps5m360m0000gn/T/calibre_0.8.12_tmp_q4Glu5/calibre_0.8.12_kYXVOH.opf',
'remove_fake_margins': True,
'remove_first_image': False,
'remove_paragraph_spacing': False,
'remove_paragraph_spacing_indent_size': 1.5,
'renumber_headings': True,
'replace_scene_breaks': u'',
'rescale_images': False,
'series': None,
'series_index': None,
'smarten_punctuation': False,
'sr1_replace': None,
'sr1_search': None,
'sr2_replace': None,
'sr2_search': None,
'sr3_replace': None,
'sr3_search': None,
'tags': None,
'timestamp': None,
'title': None,
'title_sort': None,
'toc_filter': None,
'toc_threshold': 6,
'toc_title': None,
'unwrap_lines': True,
'use_auto_toc': False,
'verbose': 2}
InputFormatPlugin: HTML Input running
on /var/folders/4l/7q0n1hkn7y3dg76kps5m360m0000gn/T/calibre_0.8.12_tmp_q4Glu5/calibre_0.8.12_wHKKPr_plumber_archive/content.opf
Parsing all content...
Manifest item 'toc.ncx' not found
Parsing Attempt.html ...
Generating default TOC from spine...
Merging user specified metadata...
Python function terminated unexpectedly: Unregistered function
Detecting structure...
Traceback (most recent call last):
File "/Users/lucille/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 147, in main
return run_entry_point()
File "/Users/lucille/Applications/calibre.app/Contents/Resources/Python/lib/python2.7/site.py", line 116, in run_entry_point
return getattr(pmod, func)()
File "site-packages/calibre/utils/ipc/worker.py", line 181, in main
File "site-packages/calibre/gui2/convert/gui_conversion.py", line 31, in gui_convert_override
File "site-packages/calibre/gui2/convert/gui_conversion.py", line 25, in gui_convert
File "site-packages/calibre/ebooks/conversion/plumber.py", line 975, in run
File "site-packages/calibre/ebooks/oeb/transforms/structure.py", line 33, in __call__
File "site-packages/calibre/ebooks/oeb/transforms/structure.py", line 76, in detect_chapters
File "xpath.pxi", line 430, in lxml.etree.XPath.__call__ (src/lxml/lxml.etree.c:105242)
File "xpath.pxi", line 212, in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:103335)
File "xpath.pxi", line 197, in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:103158)
lxml.etree.XPathEvalError: Unregistered function

Last edited by Starson17; 08-04-2011 at 04:01 PM. Reason: Add spoilers
Tearin de Hairou is offline   Reply With Quote
Old 08-04-2011, 03:20 PM   #8
PeterT
Taking a break; Fed up
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.
 
PeterT's Avatar
 
Posts: 7,355
Karma: 46281507
Join Date: Nov 2007
Location: Toronto
Device: Wife: Touch, Arc, Vox Me: Nexus 7, Glo
Quote:
Originally Posted by Tearin de Hairou View Post
Sorry, Peter, wrap items like what? And where do the code and anti-code blocks go? And do they have angle brackets around them?
I was trying to show that when you post items like RECIPES or CODE in general, wrapping them in the MobileRead forums in [ CODE ] [ / CODE ] blocks ensure that they are not scanned for items like smiley faces. Please compare your original post to what I quoted back!
PeterT is online now   Reply With Quote
Old 08-04-2011, 03:58 PM   #9
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
Sorry, misunderstood. I've found that if I leave Calibre's 'Convert books' dialogue, in the section 'Structure detection', with the path 'Detect chapters at (XPath expression):' field filled in automatically like this:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part|prologue|epilogue\s+', 'i')) or @class = 'chapter']
and with the same 'Structure detection' section's field 'Insert page breaks before (XPath expression): filled in automatically like this:
Code:
//*[name()='h1' or name()='h2']
and with the 'Table of Contents' section filled in (by me) like this:
Code:
//h:p[re:test(@class, "chapter", "i")]
then the result when I ok that dialogue and save the book is that this seems to work.

However, I haven't yet worked out how to get the paragraphs to sit close together like a normal book; there's vast leading between them. Is there any way to open a .mobi file and look at it, so I could look into one that *does* work and see what they've done?
Tearin de Hairou is offline   Reply With Quote
Old 08-04-2011, 04:10 PM   #10
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
controlling paragraph spacing is done under 'Look & Feel'. You can either enable the 'remove spacing between paragraphs' option, or control it yourself with extra css. Extra css is more complicated but provides finer grained control.

Another user was just asking for something similar, it's discussed ad-nauseum in this thread:
http://www.mobileread.com/forums/sho...d.php?t=144597

Look for the extra css options in the second half of the discussion for examples.
ldolse is offline   Reply With Quote
Old 08-04-2011, 04:37 PM   #11
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
Thanks so much!

oh....but...didn't work.

I'm now really tearing de hair out; I've got a .mobi that has the title and chapter the same size as the text, whereas when I open the html page in Safari, they look nice and big.

And I've got *two* contents lists; one at the beginning, one at the end.

(By the way, I'm having to log in every time I post; is there a setting that keeps me logged in? I've checked the 'Remember me' option ok.)

Last edited by Tearin de Hairou; 08-04-2011 at 04:55 PM.
Tearin de Hairou is offline   Reply With Quote
Old 08-04-2011, 05:29 PM   #12
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 say it didn't work but now you're asking about different problems...

For the chapter header sizing, please note that Mobi is extremely limited in it's styling capabilities. It's possible your 1.2em style isn't large enough to get translated to something heavier weight in mobi. Generally best practice for any document is to use <h1>, <h2>, or <h3> tags instead of <p> tags around chapter headings. I realize that's probably not news you want to hear. What you could try is editing the css to make it larger than 1.2em and see if that helps.

Regarding the duplicate inline chapters, that's expected behavior, several links to read up on that:
http://www.calibre-ebook.com/user_ma...-in-mobi-files

Solution: http://www.mobileread.com/forums/sho...0&postcount=11

http://www.mobileread.com/forums/sho...d.php?t=129364
ldolse is offline   Reply With Quote
Old 08-04-2011, 07:02 PM   #13
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
Thanks for your help, Idolse. Yes, I said it didn't work *and* now I'm asking about different problems!
The weird thing about this is that I'm looking at two sets of html printed out side by side. No difference that I can see between them. But one is outputting to a book with a sized-up title page and chapters, and the other isn't. (Both have the wide space between paragraphs.)
I'll read the links you've kindly provided in the morning and see if they may help.
Tearin de Hairou is offline   Reply With Quote
Old 08-04-2011, 10:57 PM   #14
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'd need to post some snippets of your actual html to get a more certain suggestion. If the functions I mentioned before didn't work the most likely reason for the failure is that there is a hard-coded blank line between every paragraph. You can try removing this by going to heuristics and enabling the option to attempt to remove them - you probably also want to enable scene break detection if you do that.
ldolse is offline   Reply With Quote
Old 08-05-2011, 05:49 AM   #15
Tearin de Hairou
Junior Member
Tearin de Hairou began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Aug 2011
Device: Kindle
Thank you very much, Idolse. Here's the code that didn't work:

Code:
<head>
<style type="text/css">
html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dd, dt, p, pre, table, th, td, tr, {margin: 0; padding: 0em; }
p
{
	text-indent: 1.5em;
	margin-bottom: 0.2em;

}
p.chapter
{
text-indent: 1.5em;
font-weight: bold;
font-size: 2em;
page-break-before: always;
margin-top: 5em;
margin-bottom: 2em;
}
p.centered

{
text-indent: 0em;

text-align: center;

}

span.centered

{

text-indent: 0em;
text-align: center;

}
p.title
{
text-indent: 0em;
text-align: center;
font-weight: bold;
font-size: 4em;
page-break-before: always;
margin-top: 5em;
margin-bottom: 2em;
}
p.author
{
text-indent: 0em;
text-align: center;
font-weight: bold;
font-size: 3em;
margin-top: 0em;
margin-bottom: 2em;
}
</style>
</head>
<body>
(At the suggestion of a slightly more html-savvy friend I tried pasting this mystery incantation in at the top, but it didn't make any difference):

Code:
n="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
The text this style was affecting was this:

Code:
	<p class="title">The Boyne Walk</p>
	<p class="author">by FR Higgins</p>
<p class="chapter">More lake than river</p>
<p>Only last week, walking the hushed fields of our most lovely Meath, now thinned by November, I came to where the road from Laracor leads to the Boyne river&mdash;that seems more lake than river&mdash;stretched in uneasy light and stript of reeds. And walking alongside an old weir of my people&rsquo;s, where nothing stirs&mdash;only the shadowed leaden flight of a heron up the lean air&mdash;I went unmanly with grief, knowing how my father, happy though captive in years, walked last with me there.</p>
<p class="chapter">Heart breaks</p>
<p>Yes, happy in Meath with me for a day he walked, taking stock of herds hid in their own breathing; and naming colts, gusty as wind, once steered by his hand, lightnings winked in the eyes that were half shy in greeting old friends&mdash;the wild blades, when he gallivanted the land.</p>
<p>For that proud, wayward man now my heart breaks&mdash;breaks for that man whose mind was a secret eyrie, whose kind hand was sole signet of his race, who curbed me, scorned my green ways yet increasingly loved me till Death drew its grey blind down his face.</p>
<p>And yet I am pleased that even my reckless ways are living shades of his rich calms and passions&mdash;witnesses for him and for those faint namesakes with whom now he is one, under yew branches, yes, one in a graven silence no bird breaks.</p></body>
Tearin de Hairou 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
Table of Contents taraboom11 Sigil 20 04-30-2011 12:18 PM
Using Table of Contents sammieb77 enTourage Archive 7 01-14-2011 09:01 PM
Table of Contents ucoa Calibre 1 01-07-2011 10:01 PM
How to make a PDF table of contents work in epub ajbrutico Calibre 3 09-26-2010 10:31 AM
Help with my Table of Contents Skylinefranc Calibre 0 03-19-2010 01:55 AM


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


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