docs: def highlight_block(self, text, block):
          """
          Highlights the block using a pygments lexer.
  
          :param text: text of the block to highlith
          :param block: block to highlight
          """
          if self.color_scheme.name != self._pygments_style:
              self._pygments_style = self.color_scheme.name
              self._update_style()
          original_text = text
          if self.editor and self._lexer and self.enabled:
              if block.blockNumber():
                  prev_data = self._prev_block.userData()
                  if prev_data:
                      if hasattr(prev_data, "syntax_stack"):
                          self._lexer._saved_state_stack = prev_data.syntax_stack
                      elif hasattr(self._lexer, '_saved_state_stack'):
                          del self._lexer._saved_state_stack
  
              # Lex the text using Pygments
              index = 0
              usd = block.userData()
              if usd is None:
                  usd = TextBlockUserData()
                  block.setUserData(usd)
              tokens = list(self._lexer.get_tokens(text))
              for token, text in tokens:
                  length = len(text)
                  fmt = self._get_format(token)
                  if token in [Token.Literal.String, Token.Literal.String.Doc,
                               Token.Comment]:
                      fmt.setObjectType(fmt.UserObject)
                  self.setFormat(index, length, fmt)
                  index += length
  
              if hasattr(self._lexer, '_saved_state_stack'):
                  setattr(usd, "syntax_stack", self._lexer._saved_state_stack)
                  # Clean up for the next go-round.
                  del self._lexer._saved_state_stack
  
              # spaces
              text = original_text
              expression = QRegExp(r'\s+')
              index = expression.indexIn(text, 0)
              while index >= 0:
                  index = expression.pos(0)
                  length = len(expression.cap(0))
                  self.setFormat(index, length, self._get_format(Whitespace))
                  index = expression.indexIn(text, index + length)
  
              self._prev_block = block