def hdepth(tag):
 if (not _heading_re.search(tag.name)):
  raise TaskError(u"Can't compute heading depth of non-heading {0}".format(tag))
 depth = int(tag.name[1], 10)
 cursor = tag
 while cursor:
  if (cursor.name == u'section'):
   depth += 1
  cursor = cursor.parent
 return depth

def hdepth ( tag ) : if ( not _heading_re . search ( tag . name ) ) : raise TaskError ( u"Can't compute heading depth of non-heading {0}" . format ( tag ) ) depth = int ( tag . name [ 1 ] , 10 ) cursor = tag while cursor : if ( cursor . name == u'section' ) : depth += 1 cursor = cursor . parent return depth
compute an h tags "outline depth" .