mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
version 0.4.10 with a fix for lit files that don't have a TOC.
This commit is contained in:
parent
436df36413
commit
71c2a5d4fc
@ -13,7 +13,7 @@
|
||||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
''' E-book management software'''
|
||||
__version__ = "0.4.9"
|
||||
__version__ = "0.4.10"
|
||||
__docformat__ = "epytext"
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
__appname__ = 'libprs500'
|
||||
|
@ -1607,6 +1607,7 @@ def process_file(path, options, logger=None):
|
||||
re.compile(fpba[2], re.IGNORECASE)]
|
||||
if not hasattr(options, 'anchor_ids'):
|
||||
options.anchor_ids = True
|
||||
options.use_spine = options.use_spine and options.toc.toc is not None
|
||||
files = options.spine if options.use_spine else [path]
|
||||
conv = HTMLConverter(book, fonts, options, logger, files)
|
||||
if options.use_spine:
|
||||
|
@ -64,6 +64,7 @@ class Spine(list):
|
||||
class TOC(list):
|
||||
|
||||
def __init__(self, opfreader, cwd):
|
||||
self.toc = toc = None
|
||||
try:
|
||||
toc = opfreader.soup.find('guide').find('reference', attrs={'type':'toc'})['href']
|
||||
except:
|
||||
@ -71,19 +72,21 @@ class TOC(list):
|
||||
if 'toc' in item.href.lower():
|
||||
toc = item.href
|
||||
break
|
||||
toc = urlparse(unquote(toc))[2]
|
||||
if not os.path.isabs(toc):
|
||||
toc = os.path.join(cwd, toc)
|
||||
self.toc = toc
|
||||
soup = BeautifulSoup(open(toc, 'rb').read(), convertEntities=BeautifulSoup.HTML_ENTITIES)
|
||||
for a in soup.findAll('a'):
|
||||
if not a.has_key('href'):
|
||||
continue
|
||||
href = urlparse(unquote(a['href']))[2]
|
||||
if not os.path.isabs(href):
|
||||
href = os.path.join(cwd, href)
|
||||
txt = ''.join([unicode(s).strip() for s in a.findAll(text=True)])
|
||||
self.append((href, txt))
|
||||
if toc is not None:
|
||||
toc = urlparse(unquote(toc))[2]
|
||||
if not os.path.isabs(toc):
|
||||
toc = os.path.join(cwd, toc)
|
||||
self.toc = toc
|
||||
|
||||
soup = BeautifulSoup(open(toc, 'rb').read(), convertEntities=BeautifulSoup.HTML_ENTITIES)
|
||||
for a in soup.findAll('a'):
|
||||
if not a.has_key('href'):
|
||||
continue
|
||||
href = urlparse(unquote(a['href']))[2]
|
||||
if not os.path.isabs(href):
|
||||
href = os.path.join(cwd, href)
|
||||
txt = ''.join([unicode(s).strip() for s in a.findAll(text=True)])
|
||||
self.append((href, txt))
|
||||
|
||||
|
||||
class OPFReader(MetaInformation):
|
||||
|
Loading…
x
Reference in New Issue
Block a user