docs: def _really_parse_entity(self):
          """Actually parse an HTML entity and ensure that it is valid."""
          self._emit(tokens.HTMLEntityStart())
          self._head += 1
  
          this = self._read(strict=True)
          if this == "#":
              numeric = True
              self._emit(tokens.HTMLEntityNumeric())
              self._head += 1
              this = self._read(strict=True)
              if this[0].lower() == "x":
                  hexadecimal = True
                  self._emit(tokens.HTMLEntityHex(char=this[0]))
                  this = this[1:]
                  if not this:
                      self._fail_route()
              else:
                  hexadecimal = False
          else:
              numeric = hexadecimal = False
  
          valid = "0123456789abcdefABCDEF" if hexadecimal else "0123456789"
          if not numeric and not hexadecimal:
              valid += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
          if not all([char in valid for char in this]):
              self._fail_route()
  
          self._head += 1
          if self._read() != ";":
              self._fail_route()
          if numeric:
              test = int(this, 16) if hexadecimal else int(this)
              if test < 1 or test > 0x10FFFF:
                  self._fail_route()
          else:
              if this not in htmlentities.entitydefs:
                  self._fail_route()
  
          self._emit(tokens.Text(text=this))
          self._emit(tokens.HTMLEntityEnd())