Skip to content

failure on shell commands after %%time #11

@lukas-weber

Description

@lukas-weber

Hi, thanks for your work!

I encountered the following issue when using this lexer to highlight the contents of a jupyter notebook cell.

%%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:

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()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions