View Single Post
Old 06-20-2020, 11:42 AM   #1
Mister L
Groupie
Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Posts: 159
Karma: 91148
Join Date: Jun 2010
Device: Sony 350
Add title="" to h* based on existing TOC -- suggestion for new feature (or plugin?)

How easy / possible would it be to reverse engineer an existing TOC and add the existing titles as they appear, to a title="" in an h* tag at the appropriate point in the book? If the file is really badly made and the chapter titles are in some random tag like p or div it might be necessary to add a blank h* with a display:none to it.

I'm not sure whether this is better suited to a feature in the Tools > Table of Contents menu or as a plugin (super subtle WINK to any plugin coders who are bored and looking for a new challenge...) but it would be an amazing tool to have.

Use cases:

1. you need to combine several epubs into a "collected works" file, or

2. you need to separate a "collected works" file into its individual books and make independent epubs of each,

and

the original epubs you are given have chapter headings in two (or more) parts, and/or with extraneous code in them which will make regenerating the TOC complicated, for instance :

Code:
    <h1 epub:type="title" class="part_n"><span>4</span></h1>

    <h1 epub:type="title" class="part_tit"><span>The#160;Whale speaks of#160;what#160;she has#160;learned about#160;humans</span></h1>
(note I deleted the "&" to avoid the & #160's being parsed)

Existing (desired) TOC entry :
4. The Whale speaks of what she has learned about humans

Or (even worse...)

Code:
    <h1 id="toc_marker-26">21</h1>

    <h2><span class="Cap">E</span><span class="SmallCap">N CHEMIN POUR</span> <span class="Cap">S</span><span class="SmallCap">HADAR</span> <span class="Cap">L</span><span class="SmallCap">OGOTH</span></h2>
Existing (desired) TOC entry:
21. En chemin pour Shadar Logoth

(Note, just to be PERFECTLY CLEAR, I had absolutely nothing to do with making these monstrosities originally, or I wouldn't have this problem.)


Those examples are taken straight from actual books I'm working on: last week I had to deal with case 2 and this week I've got to tackle case 1 (14 epubs, not a single one of which has chapter titles that will facilitate re-generating the TOC once I've pulled them all into the collection), and that's a lot of fiddly regex-ing and / or hand-coding 1 by 1 to copy the TOC entries into title="" (that's what I did last week because I couldn't think of a better solution, and it was pretty damned annoying just on one book, let alone 14), not for the first time and certainly not for the last either so I'm hoping that by the next time I have to deal with this there will be a better way.

If there already is a better way and I just don't know about it (I did go through the plugin index just in case...), by all means PLEASE tell me.
Mister L is offline   Reply With Quote