Exercise 3: Fixing the
  • Gap — Possible Solution ==================================================================== THE FIX ------------------------------ if tok.kind == 'opentag': top_tag = getattr(stack[-1], 'tag', None) if tok.name in P_CLOSING_TAGS and top_tag == 'p': stack.pop() elif tok.name == 'li' and top_tag == 'li': # NEW stack.pop() node = Element(tok.name, tok.attrs) stack[-1].children.append(node) stack.append(node) RESULTS ------------------------------ parse_html_fixed("") <#document>