INNER CODE UNIT · Python
run
pingbird/puro · website/pm_attr_list.py:120
def run(self, doc):
# dump_tree(doc)
parents = gather_parents(doc)
for elem in doc.iter():
parent = parents[elem] if elem in parents else None
if self.md.is_block_level(elem.tag):
# Block level: check for attrs on last line of text
pattern = self.BLOCK_RE
if isheader(elem) or elem.tag in ['dt', 'td', 'th']:
# header, def-term, or table cell: check for attrs at end of element
pattern = self.HEADER_RE
if len(elem) and elem.tag == 'li':
# special case list items. children may include an ul or ol.
pos = None
# find the ul or ol position
for i, child in enumerate(elem):
if child.tag in ['ul', 'ol']:
pos = i