Show More
@@ -45,11 +45,15 b' from IPython.utils.signatures import signature' | |||||
45 | from IPython.utils.colorable import Colorable |
|
45 | from IPython.utils.colorable import Colorable | |
46 |
|
46 | |||
47 | from pygments import highlight |
|
47 | from pygments import highlight | |
48 | from pygments.lexers import PythonLexer |
|
48 | try: | |
|
49 | # PythonLexer was renamed to Python2Lexer in pygments 2.5 | |||
|
50 | from pygments.lexers import Python2Lexer | |||
|
51 | except ImportError: | |||
|
52 | from pygments.lexers import PythonLexer as Python2Lexer | |||
49 | from pygments.formatters import HtmlFormatter |
|
53 | from pygments.formatters import HtmlFormatter | |
50 |
|
54 | |||
51 | def pylight(code): |
|
55 | def pylight(code): | |
52 | return highlight(code, PythonLexer(), HtmlFormatter(noclasses=True)) |
|
56 | return highlight(code, Python2Lexer(), HtmlFormatter(noclasses=True)) | |
53 |
|
57 | |||
54 | # builtin docstrings to ignore |
|
58 | # builtin docstrings to ignore | |
55 | _func_call_docstring = types.FunctionType.__call__.__doc__ |
|
59 | _func_call_docstring = types.FunctionType.__call__.__doc__ |
@@ -34,7 +34,12 b' This includes:' | |||||
34 | import re |
|
34 | import re | |
35 |
|
35 | |||
36 | # Third party |
|
36 | # Third party | |
37 |
from pygments.lexers import BashLexer, |
|
37 | from pygments.lexers import BashLexer, Python3Lexer | |
|
38 | try: | |||
|
39 | # PythonLexer was renamed to Python2Lexer in pygments 2.5 | |||
|
40 | from pygments.lexers import Python2Lexer | |||
|
41 | except ImportError: | |||
|
42 | from pygments.lexers import PythonLexer as Python2Lexer | |||
38 | from pygments.lexer import ( |
|
43 | from pygments.lexer import ( | |
39 | Lexer, DelegatingLexer, RegexLexer, do_insertions, bygroups, using, |
|
44 | Lexer, DelegatingLexer, RegexLexer, do_insertions, bygroups, using, | |
40 | ) |
|
45 | ) | |
@@ -87,7 +92,7 b' def build_ipy_lexer(python3):' | |||||
87 | aliases = ['ipython3'] |
|
92 | aliases = ['ipython3'] | |
88 | doc = """IPython3 Lexer""" |
|
93 | doc = """IPython3 Lexer""" | |
89 | else: |
|
94 | else: | |
90 | PyLexer = PythonLexer |
|
95 | PyLexer = Python2Lexer | |
91 | name = 'IPython' |
|
96 | name = 'IPython' | |
92 | aliases = ['ipython2', 'ipython'] |
|
97 | aliases = ['ipython2', 'ipython'] | |
93 | doc = """IPython Lexer""" |
|
98 | doc = """IPython Lexer""" |
General Comments 0
You need to be logged in to leave comments.
Login now