ipython / ipython/ipython-pygments-lexers
failure on shell commands after `%%time`
- Linguagem predominante
- Python
- Estrelas
- 0
- Forks
- 2
- Merge médio
- 12d 21h
- PRs com merge (30d)
- 1
Descrição
Hi, thanks for your work!
I encountered the following issue when using this lexer to highlight the contents of a jupyter notebook cell.
```ipython
%%time
!run_command
```
This should time the runtime of `run_command`, but instead it fails on `!` because the lexer assumes that whatever comes after `%%time` should be handled by the normal python lexer.
Reproducing snippet:
```python
from pygments import highlight
from pygments.formatters import TerminalFormatter
from pygments.lexers import get_lexer_by_name
lexer = get_lexer_by_name("ipython3")
code = "%%time\n!cmd"
print(highlight(code, lexer, TerminalFormatter()))
```
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Start with the ipython3 lexer obtained through get_lexer_by_name("ipython3") and reproduce the failure using code containing %%time followed by !cmd. Trace how the lexer handles the cell body after the cell magic; done means the example highlights successfully without treating ! as invalid Python.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- jupyter, python
- Domínio
- tooling
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 68/100