Convert page dimensions to points. Add auto-layering method to TOC.

This commit is contained in:
Marshall T. Vandegrift 2008-12-16 17:42:11 -05:00
parent 3eaede190c
commit d46abf8c50
2 changed files with 12 additions and 2 deletions

View File

@ -490,6 +490,15 @@ class TOC(object):
def __getitem__(self, 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):
if self.nodes:

View File

@ -104,8 +104,8 @@ def xpath(elem, expr):
class Page(object):
def __init__(self, width, height, dpi):
self.width = float(width)
self.height = float(height)
self.width = (float(width) / dpi) * 72.
self.height = (float(height) / dpi) * 72.
self.dpi = float(dpi)
class Profiles(object):
@ -251,6 +251,7 @@ class Stylizer(object):
rules.append('%s {\n %s;\n}' % (selector, style))
return '\n'.join(rules)
class Style(object):
def __init__(self, element, stylizer):
self._element = element