code: def highlightBlock(self, string):
          
          prev_data = self.currentBlock().previous().userData()
          if prev_data is not None:
              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
          for token, text in self._lexer.get_tokens(string):
              length = len(text)
              self.setFormat(index, length, self._get_format(token))
              index += length
  
          if hasattr(self._lexer, '_saved_state_stack'):
              data = PygmentsBlockUserData(
                  syntax_stack=self._lexer._saved_state_stack)
              self.currentBlock().setUserData(data)
              # Clean up for the next go-round.
              del self._lexer._saved_state_stack
docs: Highlight a block of text.