Skip to content

Commit

Permalink
Merge pull request #76 from fahhem/better_class
Browse files Browse the repository at this point in the history
Get the current nesting level in a smarter way
  • Loading branch information
regebro committed May 11, 2015
2 parents 48bca1e + 9cab8da commit 197957f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hovercraft/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,13 @@ def start_transition(self, node):
step = self._newstep(level)
# Walk back up to a transition of the same level
curnode = self.curnode
def get_level(clss):
for cls in clss.split():
# Skip unrelated classes, such as those added by the user.
if cls.startswith('step-level-'):
return int(cls.split('-')[-1])
while (curnode.tag != 'step' or
int(curnode.attrib['class'].split('-')[-1]) >= level):
get_level(curnode.attrib['class']) >= level):
parent = curnode.getparent()
if parent is None:
# Top of tree
Expand Down

0 comments on commit 197957f

Please sign in to comment.