View Single Post
Old 09-12-2012, 07:10 PM   #827
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,312
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
By having only one 'add_chapter_numbers' option instead of one for TOC and one for in-chapter titles, this is simplified a fair bit.

The attached version has new options:

Code:
## Don't like the numbers at the start of chapter titles on some
## sites?  You can use strip_chapter_numbers to strip them off.  Just
## want to make them all look the same?  Strip them off, then add them
## back on with add_chapter_numbers.  Don't like the way it strips
## numbers or adds them back?  See chapter_title_strip_pattern and
## chapter_title_add_pattern.
strip_chapter_numbers:true
add_chapter_numbers:true
Add them to your personal.ini (after installing, of course) to give them a try. They will be applied when an existing epub is updated. You can do 'Update Always' to change the chapter titles in existing epubs even without new chapters.

I've included default patterns for the stripping and adding that seem reasonable to me, but they're also configurable:

Spoiler:
Code:
## (Two versions of chapter_title_strip_pattern are shown below.  You
## should only have one uncommented.)
## This version will remove the leading number from:
## "1." => ""
## "1. The Beginning" => "The Beginning"
## "1: Start" => "Start"
## "2, Chapter the second" => "Chapter the second"
## etc
chapter_title_strip_pattern:^[0-9]+[\.: -]+

## This version will strip all of the above *plus* remove 'Chapter 1':
## "Chapter 1" => ""
## "1. Chapter 1" => ""
## "1. Chapter 1, Bob's First Clue" => "Bob's First Clue"
## "Chapter 2 - Pirates Place" => "Pirates Place"
## etc
#chapter_title_strip_pattern:^([0-9]+[\.: -]+)?(Chapter *[0-9]+[\.:, -]*)?

## Uses a python template substitution.  The ${index} is the 'chapter'
## number and ${title} is the chapter title, after applying
## chapter_title_strip_pattern.  Those are the only variables available.
## "The Beginning" => "1. The Beginning" 
chapter_title_add_pattern:${index}. ${title}

Last edited by JimmXinu; 09-13-2012 at 01:30 PM. Reason: Remove obsolete beta versions
JimmXinu is online now