[Enhancement] option to always use title attribute for chapter titles in TOC

Bug #1267837 reported by Steve Kertes on 2014-01-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Undecided
Unassigned

Bug Description

The calibre manuals mention how to use images as your chapter titles but still have useful text in the generated TOC by setting a title attribute:

http://manual.calibre-ebook.com/conversion.html#using-images-as-chapter-titles-when-converting-html-input-documents

For the book I was creating I did not want images but I still wanted the TOC text to be different than the tag's value.

I ended up having an empty H1 with the title attribute followed by my "real" chapter title. This was annoying.

I wanted an option to just default to using the title attribute if one was found. Something like what the attached patch does.

I have only had the calibre source for a couple hours and I'm new to python as well so I could have missed all sorts of conventions or cases but I was able to pass the flag to ebook-convert and from within the gui.

Thanks,

-steve

(tested with calibre 1.19 on OS X)

Thanks for the patch, however, I am not convinced this use case is
important enough to warrant an option of its own. Instead, you can try
doing the following, change the code that that generates toc from xpath
expressions to detect when the expression evaluates to a string and just
use the string directly, then you can use the expression

//h:h1/@title

for example, to generate the toc based on titles. Essentially the code
would have to detect if the expression endswith /@word and strip that,
then use word as the attribute to get the text and the element as the
destination.

 status incomplete

Changed in calibre:
status: New → Incomplete
Steve Kertes (kertes-e) wrote :

Thanks for the feedback. I have rewritten the feature using your suggestion and for simple xpaths it works well.

I'll make sure it works nicely with the examples on http://manual.calibre-ebook.com/xpath.html before submitting it.

-steve

Steve Kertes (kertes-e) wrote :

I didn't find any examples where people would actually want xpaths that naturally ended with /@title so I think this should be safe.

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

I have merged your patch, and added some documentation for it to the
manual.

Changed in calibre:
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers