def highlightBlock(self, string):
prev_data = self.currentBlock().previous().userData()<EOL>if prev_data is not None:<EOL><INDENT>self._lexer._saved_state_stack = prev_data.syntax_stack<EOL><DEDENT>elif hasattr(self._lexer, '<STR_LIT>'):<EOL><INDENT>del self._lexer._saved_state_stack<EOL><DEDENT>index = <NUM_LIT:0><EOL>for token, text in self._lexer.get_tokens(string):<EOL><INDENT>length = len(text)<EOL>self.setFormat(index, length, self._get_format(token))<EOL>index += length<EOL><DEDENT>if hasattr(self._lexer, '<STR_LIT>'):<EOL><INDENT>data = PygmentsBlockUserData(<EOL>syntax_stack=self._lexer._saved_state_stack)<EOL>self.currentBlock().setUserData(data)<EOL>del self._lexer._saved_state_stack<EOL><DEDENT>
Highlight a block of text.