mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Convert page dimensions to points. Add auto-layering method to TOC.
This commit is contained in:
parent
3eaede190c
commit
d46abf8c50
@ -490,6 +490,15 @@ class TOC(object):
|
|||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return self.nodes[index]
|
return self.nodes[index]
|
||||||
|
|
||||||
|
def autolayer(self):
|
||||||
|
prev = None
|
||||||
|
for node in list(self.nodes):
|
||||||
|
if prev and urldefrag(prev.href)[0] == urldefrag(node.href)[0]:
|
||||||
|
self.nodes.remove(node)
|
||||||
|
prev.nodes.append(node)
|
||||||
|
else:
|
||||||
|
prev = node
|
||||||
|
|
||||||
def depth(self, level=0):
|
def depth(self, level=0):
|
||||||
if self.nodes:
|
if self.nodes:
|
||||||
|
@ -104,8 +104,8 @@ def xpath(elem, expr):
|
|||||||
|
|
||||||
class Page(object):
|
class Page(object):
|
||||||
def __init__(self, width, height, dpi):
|
def __init__(self, width, height, dpi):
|
||||||
self.width = float(width)
|
self.width = (float(width) / dpi) * 72.
|
||||||
self.height = float(height)
|
self.height = (float(height) / dpi) * 72.
|
||||||
self.dpi = float(dpi)
|
self.dpi = float(dpi)
|
||||||
|
|
||||||
class Profiles(object):
|
class Profiles(object):
|
||||||
@ -251,6 +251,7 @@ class Stylizer(object):
|
|||||||
rules.append('%s {\n %s;\n}' % (selector, style))
|
rules.append('%s {\n %s;\n}' % (selector, style))
|
||||||
return '\n'.join(rules)
|
return '\n'.join(rules)
|
||||||
|
|
||||||
|
|
||||||
class Style(object):
|
class Style(object):
|
||||||
def __init__(self, element, stylizer):
|
def __init__(self, element, stylizer):
|
||||||
self._element = element
|
self._element = element
|
||||||
|
Loading…
x
Reference in New Issue
Block a user