Permalink
Browse files

Keep track of a TeXObject's parent (i.e. what TeXCollection contains it)

  • Loading branch information...
leonidg committed Jan 29, 2012
1 parent 72d7d89 commit a05f03b384f19d86bebac19ade86362254b31041
Showing with 4 additions and 0 deletions.
  1. +3 −0 pytex/base/collections.py
  2. +1 −0 pytex/base/objects.py
@@ -14,6 +14,8 @@ def __init__(self, objs=None, start=None, end=None, sep=None):
objs = []
elif type(objs) is not list:
objs = [objs]
+ for obj in objs:
+ obj.parent = self
self.objs = objs
if start is not None:
self.start = TeXObject(start)
@@ -22,6 +24,7 @@ def __init__(self, objs=None, start=None, end=None, sep=None):
if sep is not None:
self.sep = TeXObject(sep)
def addObj(self, obj):
+ obj.parent = self
self.objs.append(obj)
def compile(self):
start = self.start.compile()
View
@@ -12,6 +12,7 @@ class TeXObject(object):
def __init__(self, obj="", raw=False):
self.obj = obj
self.raw = raw
+ self.parent = None
def compile(self):
to_compile = self.obj
while type(to_compile) is TeXObject:

0 comments on commit a05f03b

Please sign in to comment.