Show More
@@ -0,0 +1,58 b'' | |||||
|
1 | New IPython Console Lexer | |||
|
2 | ------------------------- | |||
|
3 | ||||
|
4 | The IPython console lexer has been rewritten and now supports tracebacks | |||
|
5 | and customized input/output prompts. An entire suite of lexers are now | |||
|
6 | available at :module:`IPython.nbconvert.utils.lexers`. These include: | |||
|
7 | ||||
|
8 | IPythonLexer | |||
|
9 | IPython3Lexer | |||
|
10 | Lexers for pure IPython (python + magic/shell commands) | |||
|
11 | ||||
|
12 | IPythonPartialTracebackLexer | |||
|
13 | IPythonTracebackLexer | |||
|
14 | Supports 2.x and 3.x via the keyword `python3`. The partial traceback | |||
|
15 | lexer reads everything but the Python code appearing in a traceback. | |||
|
16 | The full lexer combines the partial lexer with an IPython lexer. | |||
|
17 | ||||
|
18 | IPythonConsoleLexer | |||
|
19 | A lexer for IPython console sessions, with support for tracebacks. | |||
|
20 | Supports 2.x and 3.x via the keyword `python3`. | |||
|
21 | ||||
|
22 | IPyLexer | |||
|
23 | A friendly lexer which examines the first line of text and from it, | |||
|
24 | decides whether to use an IPython lexer or an IPython console lexer. | |||
|
25 | Supports 2.x and 3.x via the keyword `python3`. | |||
|
26 | ||||
|
27 | Previously, the :class:`IPythonConsoleLexer` class was available at | |||
|
28 | :module:`IPython.sphinxext.ipython_console_hightlight`. It was inserted | |||
|
29 | into Pygments' list of available lexers under the name `ipython`. It should | |||
|
30 | be mentioned that this name is inaccurate. An IPython console session | |||
|
31 | is not the same as IPython code (which itself is a superset of the Python | |||
|
32 | language). | |||
|
33 | ||||
|
34 | Now, the Sphinx extension inserts two console lexers into Pygment's list of | |||
|
35 | available lexers. Both are IPyLexer instances under the names: `ipython` and | |||
|
36 | `ipython3`. As mentioned above, these names are misleading, but they are kept | |||
|
37 | for backwards compatibility and typical usage. If a project needs to make | |||
|
38 | Pygments aware of more than just the IPyLexer class, then one should not | |||
|
39 | make the IPyLexer class available under the name `ipython` and use `ipy` or | |||
|
40 | some other non-conflicting value. | |||
|
41 | ||||
|
42 | Code blocks such as:: | |||
|
43 | ||||
|
44 | .. code-block:: ipython | |||
|
45 | ||||
|
46 | In [1]: 2**2 | |||
|
47 | Out[1]: 4 | |||
|
48 | ||||
|
49 | will continue to work as before, but now, they will also properly highlight | |||
|
50 | tracebacks. For pure IPython code, the same lexer will work:: | |||
|
51 | ||||
|
52 | .. code-block:: ipython | |||
|
53 | ||||
|
54 | x = ''.join(map(str, range(10))) | |||
|
55 | !echo $x | |||
|
56 | ||||
|
57 | Since the first line of the block did not begin with a standard IPython console | |||
|
58 | prompt, the entire block is assumed to be IPython code instead. |
General Comments 0
You need to be logged in to leave comments.
Login now