Add add_chapter_numbers: toconly option.

This commit is contained in:
Jim Miller
2012-09-30 15:47:18 -05:00
parent ca31872a9f
commit 2fcdbca766
5 changed files with 22 additions and 17 deletions
+9 -6
View File
@@ -184,10 +184,14 @@ keep_summary_html:true
## 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.
## back on with add_chapter_numbers:true. Only want them added back
## on for Table of Contents(toc)? Use add_chapter_numbers:toconly.
## (toconly doesn't work on mobi output.) 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:false
## add_chapter_numbers can be true, false or toconly
add_chapter_numbers:false
## (Two versions of chapter_title_strip_pattern are shown below. You
@@ -556,9 +560,8 @@ cliches_label:Character Cliches
## specific entries to titlepage/logpage without having to copy the
## entire titlepage_entries line. (But if you want them higher than
## the end, you will need to copy titlepage_entries.)
#extra_titlepage_entries: themes,hermiones,dracos,timeline,cliches
## adds to include_subject_tags instead of replacing it.
#extra_titlepage_entries: themes,timeline,cliches
#extra_logpage_entries: themes,timeline,cliches
#extra_subject_tags: themes,timeline,cliches
[erosnsappho.sycophanthex.com]
+4 -3
View File
@@ -411,11 +411,12 @@ class Story(Configurable):
title = re.sub(self.getConfig('chapter_title_strip_pattern'),"",title)
self.chapters.append( (title,html) )
def getChapters(self):
def getChapters(self,fortoc=False):
"Chapters will be tuples of (title,html)"
retval = []
if self.getConfig('add_chapter_numbers') and \
self.getConfig('chapter_title_add_pattern'):
if (self.getConfig('add_chapter_numbers') == "true" \
or (self.getConfig('add_chapter_numbers') == "toconly" and fortoc)) \
and self.getConfig('chapter_title_add_pattern'):
for index, (title,html) in enumerate(self.chapters):
retval.append( (string.Template(self.getConfig('chapter_title_add_pattern')).substitute({'index':index+1,'title':title}),html) )
else:
+1 -1
View File
@@ -148,7 +148,7 @@ class BaseStoryWriter(Configurable):
if len(self.story.getChapters()) > 1 and self.getConfig("include_tocpage") and not self.metaonly :
self._write(out,START.substitute(self.story.getAllMetadata()))
for index, (title,html) in enumerate(self.story.getChapters()):
for index, (title,html) in enumerate(self.story.getChapters(fortoc=True)):
if html:
self._write(out,ENTRY.substitute({'chapter':title, 'index':"%04d"%(index+1)}))
+1 -1
View File
@@ -451,7 +451,7 @@ div { margin: 0pt; padding: 0pt; }
items.append(("log_page","OEBPS/log_page.xhtml","application/xhtml+xml","Update Log"))
itemrefs.append("log_page")
for index, (title,html) in enumerate(self.story.getChapters()):
for index, (title,html) in enumerate(self.story.getChapters(fortoc=True)):
if html:
i=index+1
items.append(("file%04d"%i,
+7 -6
View File
@@ -168,10 +168,14 @@ keep_summary_html:true
## 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.
## back on with add_chapter_numbers:true. Only want them added back
## on for Table of Contents(toc)? Use add_chapter_numbers:toconly.
## (toconly doesn't work on mobi output.) 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:false
## add_chapter_numbers can be true, false or toconly
add_chapter_numbers:false
## (Two versions of chapter_title_strip_pattern are shown below. You
@@ -557,9 +561,6 @@ cliches_label:Character Cliches
# themes=>#bcolumn,a
# timeline=>#ccolumn,n
## adds to include_subject_tags instead of replacing it.
#extra_subject_tags: themes,timeline,cliches
[erosnsappho.sycophanthex.com]
## Site dedicated to these categories/characters/ships
extracategories:Harry Potter