Show More
@@ -108,6 +108,7 b" def _pygments_highlight(source, output_formatter, language='ipython', metadata=N" | |||||
108 | """ |
|
108 | """ | |
109 | from pygments import highlight |
|
109 | from pygments import highlight | |
110 | from pygments.lexers import get_lexer_by_name |
|
110 | from pygments.lexers import get_lexer_by_name | |
|
111 | from pygments.util import ClassNotFound | |||
111 | from IPython.nbconvert.utils.lexers import IPythonLexer, IPython3Lexer |
|
112 | from IPython.nbconvert.utils.lexers import IPythonLexer, IPython3Lexer | |
112 |
|
113 | |||
113 | # If the cell uses a magic extension language, |
|
114 | # If the cell uses a magic extension language, | |
@@ -123,6 +124,12 b" def _pygments_highlight(source, output_formatter, language='ipython', metadata=N" | |||||
123 | elif language == 'ipython3': |
|
124 | elif language == 'ipython3': | |
124 | lexer = IPython3Lexer() |
|
125 | lexer = IPython3Lexer() | |
125 | else: |
|
126 | else: | |
126 | lexer = get_lexer_by_name(language, stripall=True) |
|
127 | try: | |
|
128 | lexer = get_lexer_by_name(language, stripall=True) | |||
|
129 | except ClassNotFound: | |||
|
130 | warn("No lexer found for language %r. Treating as plain text." % language) | |||
|
131 | from pygments.lexers.special import TextLexer | |||
|
132 | lexer = TextLexer() | |||
|
133 | ||||
127 |
|
134 | |||
128 | return highlight(source, lexer, output_formatter) |
|
135 | return highlight(source, lexer, output_formatter) |
General Comments 0
You need to be logged in to leave comments.
Login now