class_docstr: Override `HTMLExtractor` and create `etree` `Elements` for any elements which should have content parsed as
  Markdown.
code: def handle_endtag(self, tag):
      if tag in self.block_level_tags:
          if self.inraw:
              super().handle_endtag(tag)
          elif tag in self.mdstack:
              # Close element and any unclosed children
              while self.mdstack:
                  item = self.mdstack.pop()
                  self.mdstate.pop()
                  self.treebuilder.end(item)
                  if item == tag:
                      break
              if not self.mdstack:
                  # Last item in stack is closed. Stash it
                  element = self.get_element()
                  # Get last entry to see if it ends in newlines
                  # If it is an element, assume there is no newlines
                  item = self.cleandoc[-1] if self.cleandoc else ""
                  # If we only have one newline before block element, add another
                  if not item.endswith("\n\n") and item.endswith("\n"):
                      self.cleandoc.append("\n")
                  self.cleandoc.append(self.md.htmlStash.store(element))
                  self.cleandoc.append("\n\n")
                  self.state = []
                  # Check if element has a tail
                  if not blank_line_re.match(
                      self.rawdata[
                          self.line_offset
                          + self.offset
                          + len(self.get_endtag_text(tag)) :
                      ]
                  ):
                      # More content exists after `endtag`.
                      self.intail = True
          else:
              # Treat orphan closing tag as a span level tag.
              text = self.get_endtag_text(tag)
              if self.mdstate and self.mdstate[-1] == "off":
                  self.handle_data(self.md.htmlStash.store(text))
              else:
                  self.handle_data(text)
      else:
          # Span level tag
          if self.inraw:
              super().handle_endtag(tag)
          else:
              text = self.get_endtag_text(tag)
              if self.mdstate and self.mdstate[-1] == "off":
                  self.handle_data(self.md.htmlStash.store(text))
              else:
                  self.handle_data(text)
  
imports: from __future__ import annotations
  from .None import Extension
  from ..blockprocessors import BlockProcessor
  from ..preprocessors import Preprocessor
  from ..postprocessors import RawHtmlPostprocessor
  from ..None import util
  from ..htmlparser import HTMLExtractor, blank_line_re
  import xml.etree.ElementTree
  from typing import TYPE_CHECKING, Literal, Mapping
label_desc: Use image node_id 7 for calling the HTMLExtractorExtra obj's underlying member method code with example usage: obj.handle_endtag(tag) without return types