mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-30 23:00:21 -04:00
Catalog tweaks
This commit is contained in:
commit
24154c259d
@ -1,4 +1,4 @@
|
||||
import datetime, htmlentitydefs, os, re, shutil, time, traceback
|
||||
import datetime, htmlentitydefs, os, re, shutil, time
|
||||
|
||||
from collections import namedtuple
|
||||
from copy import deepcopy
|
||||
@ -2205,9 +2205,23 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
textTag = Tag(ncx_soup, "text")
|
||||
if book['series']:
|
||||
tokens = book['title'].split(': ')
|
||||
textTag.insert(0, NavigableString(self.formatNCXText('%s (%s)' % (tokens[1], tokens[0]), dest='title')))
|
||||
if self.generateForKindle:
|
||||
# Don't include Author for Kindle
|
||||
textTag.insert(0, NavigableString(self.formatNCXText('%s (%s)' % \
|
||||
(tokens[1], tokens[0]), dest='title')))
|
||||
else:
|
||||
# Include Author for non-Kindle
|
||||
textTag.insert(0, NavigableString(self.formatNCXText('%s · %s (%s)' % \
|
||||
(tokens[1], book['author'], tokens[0]), dest='title')))
|
||||
else:
|
||||
textTag.insert(0, NavigableString(self.formatNCXText(book['title'], dest='title')))
|
||||
if self.generateForKindle:
|
||||
# Don't include Author for Kindle
|
||||
textTag.insert(0, NavigableString(self.formatNCXText('%s' % (book['title']),
|
||||
dest='title')))
|
||||
else:
|
||||
# Include Author for non-Kindle
|
||||
textTag.insert(0, NavigableString(self.formatNCXText('%s · %s' % \
|
||||
(book['title'], book['author']), dest='title')))
|
||||
navLabelTag.insert(0,textTag)
|
||||
navPointVolumeTag.insert(0,navLabelTag)
|
||||
|
||||
@ -2221,7 +2235,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
cmTag['name'] = "author"
|
||||
navStr = '%s | %s' % (self.formatNCXText(book['author'], dest='author'),
|
||||
book['date'].split()[1])
|
||||
if 'tags' in book:
|
||||
if 'tags' in book and len(book['tags']):
|
||||
navStr = self.formatNCXText(navStr + ' | ' + ' · '.join(sorted(book['tags'])), dest='author')
|
||||
cmTag.insert(0, NavigableString(navStr))
|
||||
navPointVolumeTag.insert(2, cmTag)
|
||||
@ -3284,10 +3298,10 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
Deprecated HTML returns as HTML via BeautifulSoup()
|
||||
|
||||
'''
|
||||
|
||||
# Explode lost CRs to \n\n
|
||||
# Hackish - ignoring sentences ending or beginning in numbers to avoid
|
||||
# confusion with decimal points.
|
||||
|
||||
# Explode lost CRs to \n\n
|
||||
for lost_cr in re.finditer('([a-z])([\.\?!])([A-Z])',comments):
|
||||
comments = comments.replace(lost_cr.group(),
|
||||
'%s%s\n\n%s' % (lost_cr.group(1),
|
||||
@ -3309,6 +3323,8 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
# Convert solo returns to <br />
|
||||
comments = re.sub('[\r\n]','<br />', comments)
|
||||
|
||||
# Convert two hypens to emdash
|
||||
comments = re.sub('--','—',comments)
|
||||
soup = BeautifulSoup(comments)
|
||||
|
||||
result = BeautifulSoup()
|
||||
|
Loading…
x
Reference in New Issue
Block a user