View Single Post
Old 10-02-2010, 11:53 AM   #6
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
By the way, even if you do enable preprocessing, you would still need to follow Jackie's advice about Calibre's settings under structure detection/TOC to actually build the Table of Contents. Preprocessing takes those common types of chapter headings I mentioned and wraps them in <h2> tags, but then the structure detection settings must still match how the chapters are defined.

The default rule is this:
Code:
//*[((name()='h1' or name()='h2') and re:test(., 'chapter|book|section|part\s+', 'i')) or @class = 'chapter']
With that and preprocessing you would get an automatically generated TOC if your book happened to use Chapter xxx, or one of the other words in that pattern.

You can change that simply follow Jackie's advice to match all h2 headers in structure detection and TOC creation:
Code:
//h:h2
I'll often just edit the existing xpath though, to match numbers:
Code:
//*[((name()='h1' or name()='h2') and re:test(., '\d+', 'i')) or @class = 'chapter']
or anything:
Code:
//*[((name()='h1' or name()='h2') and re:test(., '.*', 'i')) or @class = 'chapter']
That last one basically does the same as Jackie's suggestion, but all you need to remember is to change the words to '.*' or '\d+'

Last edited by ldolse; 10-02-2010 at 11:59 AM.
ldolse is offline   Reply With Quote