This commit is contained in:
Kovid Goyal 2013-03-14 14:44:27 +05:30
parent 89a6733a92
commit 3e718aa4d6

View File

@ -57,6 +57,16 @@ class TOC(object):
except ValueError:
return 1
def get_lines(self, lvl=0):
frag = ('#'+self.frag) if self.frag else ''
ans = [(u'\t'*lvl) + u'TOC: %s --> %s%s'%(self.title, self.dest, frag)]
for child in self:
ans.extend(child.get_lines(lvl+1))
return ans
def __str__(self):
return b'\n'.join([x.encode('utf-8') for x in self.get_lines()])
def child_xpath(tag, name):
return tag.xpath('./*[calibre:lower-case(local-name()) = "%s"]'%name)