Return token list for Python string.
(result: str)
| 428 | |
| 429 | |
| 430 | def _lex_python_result(result: str) -> Generator[tuple[str, str], None, None]: |
| 431 | "Return token list for Python string." |
| 432 | lexer = PythonLexer() |
| 433 | # Use `get_tokens_unprocessed`, so that we get exactly the same string, |
| 434 | # without line endings appended. `print_formatted_text` already appends a |
| 435 | # line ending, and otherwise we'll have two line endings. |
| 436 | tokens = lexer.get_tokens_unprocessed(result) |
| 437 | |
| 438 | for index, tokentype, text in tokens: |
| 439 | yield ("class:" + pygments_token_to_classname(tokentype), text) |
no outgoing calls
no test coverage detected