Show More
@@ -43,7 +43,7 b' default_filters = {' | |||
|
43 | 43 | 'ansi2html': filters.ansi2html, |
|
44 | 44 | 'filter_data_type': filters.DataTypeFilter, |
|
45 | 45 | 'get_lines': filters.get_lines, |
|
46 |
'highlight2html': filters. |
|
|
46 | 'highlight2html': filters.Highlight2Html, | |
|
47 | 47 | 'highlight2latex': filters.highlight2latex, |
|
48 | 48 | 'ipython2python': filters.ipython2python, |
|
49 | 49 | 'posix_path': filters.posix_path, |
@@ -18,6 +18,8 b' from pygments import highlight as pygements_highlight' | |||
|
18 | 18 | from pygments.lexers import get_lexer_by_name |
|
19 | 19 | from pygments.formatters import HtmlFormatter |
|
20 | 20 | from pygments.formatters import LatexFormatter |
|
21 | from IPython.config import catch_config_error, Configurable | |
|
22 | from IPython.utils.traitlets import Unicode | |
|
21 | 23 | |
|
22 | 24 | # Our own imports |
|
23 | 25 | from IPython.nbconvert.utils.lexers import IPythonLexer |
@@ -33,12 +35,16 b" MULTILINE_OUTPUTS = ['text', 'html', 'svg', 'latex', 'javascript', 'json']" | |||
|
33 | 35 | #----------------------------------------------------------------------------- |
|
34 | 36 | |
|
35 | 37 | __all__ = [ |
|
36 |
' |
|
|
38 | 'Highlight2Html', | |
|
37 | 39 | 'highlight2latex' |
|
38 | 40 | ] |
|
39 | 41 | |
|
40 | 42 | |
|
41 | def highlight2html(source, language='ipython', metadata=None): | |
|
43 | class Highlight2Html(Configurable): | |
|
44 | ||
|
45 | language = Unicode('ipython', config=True, help='default highlight language') | |
|
46 | ||
|
47 | def __call__(self, source, language=None, metadata=None): | |
|
42 | 48 | """ |
|
43 | 49 | Return a syntax-highlighted version of the input source as html output. |
|
44 | 50 | |
@@ -51,6 +57,8 b" def highlight2html(source, language='ipython', metadata=None):" | |||
|
51 | 57 | metadata : NotebookNode cell metadata |
|
52 | 58 | metadata of the cell to highlight |
|
53 | 59 | """ |
|
60 | if not language: | |
|
61 | language=self.language | |
|
54 | 62 | |
|
55 | 63 | return _pygment_highlight(source, HtmlFormatter(), language, metadata) |
|
56 | 64 |
General Comments 0
You need to be logged in to leave comments.
Login now