##// END OF EJS Templates
Almost have nbconvert working again...
Jonathan Frederic -
Show More
@@ -92,7 +92,7 b' class NbconvertApp(Application):'
92 92
93 93 #Export
94 94 output, resources, exporter = export_by_name(ipynb_file, export_type)
95
95
96 96 destination_filename = None
97 97 destination_directory = None
98 98 if exporter.write:
@@ -149,7 +149,7 b' def main():'
149 149
150 150 app = NbconvertApp.instance()
151 151 app.description = __doc__
152 app.run(argv=sys.argv)
152 app.start(argv=sys.argv)
153 153
154 154 if __name__ == '__main__':
155 155 main() No newline at end of file
@@ -39,7 +39,7 b' import nbconvert.filters.strings'
39 39 import nbconvert.filters.markdown
40 40 import nbconvert.filters.latex
41 41 import nbconvert.filters.datatypefilter
42 import nbconvert.filters.pygments
42 import nbconvert.filters.highlight
43 43 import nbconvert.filters.ansi
44 44
45 45 import nbconvert.transformers.extractfigure
@@ -184,9 +184,9 b' class Exporter(Configurable):'
184 184 self.register_filter('ansi2html', nbconvert.filters.ansi.ansi2html)
185 185 self.register_filter('filter_data_type', nbconvert.filters.datatypefilter.DataTypeFilter)
186 186 self.register_filter('get_lines', nbconvert.filters.strings.get_lines)
187 self.register_filter('highlight', nbconvert.filters.pygments.highlight)
188 self.register_filter('highlight2html', nbconvert.filters.pygments.highlight)
189 self.register_filter('highlight2latex', nbconvert.filters.pygments.highlight2latex)
187 self.register_filter('highlight', nbconvert.filters.highlight.highlight)
188 self.register_filter('highlight2html', nbconvert.filters.highlight.highlight)
189 self.register_filter('highlight2latex', nbconvert.filters.highlight.highlight2latex)
190 190 self.register_filter('markdown2latex', nbconvert.filters.markdown.markdown2latex)
191 191 self.register_filter('markdown2rst', nbconvert.filters.markdown.markdown2rst)
192 192 self.register_filter('pycomment', nbconvert.filters.strings.python_comment)
@@ -35,7 +35,7 b' class HtmlExporter(exporter.Exporter):'
35 35 def _register_transformers(self):
36 36
37 37 #Register the transformers of the base class.
38 super(exporter.Exporter, self)._register_transformers()
38 super(HtmlExporter, self)._register_transformers()
39 39
40 40 #Register latex transformer
41 41 self.register_transformer(nbconvert.transformers.csshtmlheader.CSSHtmlHeaderTransformer)
@@ -22,15 +22,15 b' from jinja2 import Environment, FileSystemLoader'
22 22 # local import
23 23 import exporter
24 24 import nbconvert.filters.latex
25 import nbconvert.filters.pygments
25 import nbconvert.filters.highlight
26 26 from nbconvert.transformers.latex import LatexTransformer
27 27 #-----------------------------------------------------------------------------
28 28 # Globals and constants
29 29 #-----------------------------------------------------------------------------
30 30
31 31 #Latex Jinja2 constants
32 LATEX_TEMPLATE_PATH = "/../templates/tex/"
33 LATEX_TEMPLATE_SKELETON_PATH = "/../templates/tex/skeleton/"
32 LATEX_TEMPLATE_PATH = "/../templates/latex/"
33 LATEX_TEMPLATE_SKELETON_PATH = "/../templates/latex/skeleton/"
34 34
35 35 #Special Jinja2 syntax that will not conflict when exporting latex.
36 36 LATEX_JINJA_COMMENT_BLOCK = ["((=", "=))"]
@@ -50,13 +50,13 b' class LatexExporter(exporter.Exporter):'
50 50 help="Extension of the file that should be written to disk")
51 51
52 52 template_file = Unicode(
53 'latex_base', config=True,
53 'base', config=True,
54 54 help="Name of the template file to use")
55 55
56 56 def __init__(self, preprocessors=None, jinja_filters=None, config=None, **kw):
57 57
58 58 #Call base class constructor.
59 super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw)
59 super(LatexExporter, self).__init__(preprocessors, jinja_filters, config, **kw)
60 60
61 61 self.extract_figure_transformer.display_data_priority = ['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text']
62 62 self.extract_figure_transformer.extra_ext_map={'svg':'pdf'}
@@ -83,16 +83,16 b' class LatexExporter(exporter.Exporter):'
83 83 def _register_filters(self):
84 84
85 85 #Register the filters of the base class.
86 super(exporter.Exporter, self)._register_filters()
86 super(LatexExporter, self)._register_filters()
87 87
88 88 #Add latex filters to the Jinja2 environment
89 self.register_filter('escape_tex', filters.latex.escape_tex)
90 self.register_filter('highlight', filters.pygments.highlight2latex)
89 self.register_filter('escape_tex', nbconvert.filters.latex.escape_tex)
90 self.register_filter('highlight', nbconvert.filters.highlight.highlight2latex)
91 91
92 92 def _register_transformers(self):
93 93
94 94 #Register the transformers of the base class.
95 super(exporter.Exporter, self)._register_transformers()
95 super(LatexExporter, self)._register_transformers()
96 96
97 97 #Register latex transformer
98 98 self.register_transformer(LatexTransformer)
@@ -33,7 +33,7 b' class PythonExporter(exporter.Exporter):'
33 33 def __init__(self, preprocessors=None, jinja_filters=None, config=None, armor=False, **kw):
34 34
35 35 #Call base class constructor.
36 super(exporter.Exporter, self).__init__(preprocessors, jinja_filters, config, **kw)
36 super(PythonExporter, self).__init__(preprocessors, jinja_filters, config, **kw)
37 37
38 38 #Set defaults
39 39 self.extract_figure_transformer.enabled = False
@@ -34,8 +34,8 b' class RevealExporter(html.HtmlExporter):'
34 34 def _register_transformers(self):
35 35
36 36 #Register the transformers of the base class.
37 super(html_exporter.HtmlExporter, self)._register_transformers()
37 super(RevealExporter, self)._register_transformers()
38 38
39 39 #Register reveal help transformer
40 self.register_transformer(transformers.revealhelp.RevealHelpTransformer)
40 self.register_transformer(nbconvert.transformers.revealhelp.RevealHelpTransformer)
41 41 No newline at end of file
@@ -21,13 +21,13 b' from nbconvert.transformers.sphinx import SphinxTransformer'
21 21 class SphinxExporter(latex.LatexExporter):
22 22
23 23 template_file = Unicode(
24 'sphinxhowto', config=True,
24 'sphinx_howto', config=True,
25 25 help="Name of the template file to use")
26 26
27 27 def _register_transformers(self):
28 28
29 29 #Register the transformers of the base class.
30 super(latex.LatexExporter, self)._register_transformers()
30 super(SphinxExporter, self)._register_transformers()
31 31
32 32 #Register sphinx latex transformer
33 33 self.register_transformer(SphinxTransformer)
@@ -22,10 +22,9 b' class DataTypeFilter(object):'
22 22 display_data_priority = None
23 23
24 24 def __init__(self, display_data_priority):
25 super(object, self).__init__()
26 25
27 26 #Make sure that the display data priority variably is not None.
28 if self.display_data_priority is None:
27 if display_data_priority is None:
29 28 raise TypeError
30 29 else:
31 30 self.display_data_priority = display_data_priority
@@ -1,3 +1,9 b''
1
2 from pygments import highlight as pygements_highlight
3 from pygments.lexers import get_lexer_by_name
4 from pygments.formatters import HtmlFormatter
5 from pygments.formatters import LatexFormatter
6
1 7 # Our own imports
2 8 from nbconvert.utils.lexers import IPythonLexer
3 9
@@ -14,26 +20,22 b" def highlight(src, lang='ipython'):"
14 20 """
15 21 Return a syntax-highlighted version of the input source as html output.
16 22 """
17 from pygments.formatters import HtmlFormatter
18 return pygment_highlight(src, HtmlFormatter(), lang)
23
24 return _pygment_highlight(src, HtmlFormatter(), lang)
19 25
20 26 def highlight2latex(src, lang='ipython'):
21 27 """
22 28 Return a syntax-highlighted version of the input source as latex output.
23 29 """
24 from pygments.formatters import LatexFormatter
25 return pygment_highlight(src, LatexFormatter(), lang)
30 return _pygment_highlight(src, LatexFormatter(), lang)
26 31
27 def pygment_highlight(src, output_formatter, lang='ipython'):
32 def _pygment_highlight(src, output_formatter, lang='ipython'):
28 33 """
29 34 Return a syntax-highlighted version of the input source
30 35 """
31 from pygments import highlight
32 from pygments.lexers import get_lexer_by_name
33
34 36 if lang == 'ipython':
35 37 lexer = IPythonLexer()
36 38 else:
37 39 lexer = get_lexer_by_name(lang, stripall=True)
38 40
39 return highlight(src, lexer, output_formatter)
41 return pygements_highlight(src, lexer, output_formatter)
@@ -28,7 +28,7 b' consider calling super even if it is a leave block, we might insert more blocks '
28 28 ((*- for worksheet in nb.worksheets -*))
29 29 ((*- for cell in worksheet.cells -*))
30 30 ((*- block any_cell scoped -*))
31 ((*- if cell.type in ['code'] -*))
31 ((*- if cell.cell_type in ['code'] -*))
32 32 ((*- block codecell scoped -*))
33 33 ((*- block input_group -*))
34 34 ((*- block in_prompt -*))((*- endblock in_prompt -*))
@@ -70,13 +70,13 b' consider calling super even if it is a leave block, we might insert more blocks '
70 70 ((*- endblock output_group -*))
71 71 ((*- endif -*))
72 72 ((*- endblock codecell -*))
73 ((*- elif cell.type in ['markdown'] -*))
73 ((*- elif cell.cell_type in ['markdown'] -*))
74 74 ((*- block markdowncell scoped-*))
75 75 ((*- endblock markdowncell -*))
76 ((*- elif cell.type in ['heading'] -*))
76 ((*- elif cell.cell_type in ['heading'] -*))
77 77 ((*- block headingcell scoped-*))
78 78 ((*- endblock headingcell -*))
79 ((*- elif cell.type in ['raw'] -*))
79 ((*- elif cell.cell_type in ['raw'] -*))
80 80 ((*- block rawcell scoped-*))
81 81 ((*- endblock rawcell -*))
82 82 ((*- else -*))
@@ -3,7 +3,7 b''
3 3 Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the
4 4 template is derived directly from Sphinx source.
5 5
6 Inheritance: null>display_priority>latex_base
6 Inheritance: null>display_priority
7 7
8 8 Note: For best display, use latex syntax highlighting. =))
9 9
@@ -8,7 +8,7 b''
8 8
9 9 ==========================================================================))
10 10
11 ((*- extends 'latex_sphinx_base.tplx' -*))
11 ((*- extends 'sphinx_base.tplx' -*))
12 12
13 13 ((* set parentdocumentclass = 'article' *))
14 14 ((* set documentclass = 'howto' *))
@@ -8,7 +8,7 b''
8 8
9 9 ==========================================================================))
10 10
11 ((*- extends 'latex_sphinx_base.tplx' -*))
11 ((*- extends 'sphinx_base.tplx' -*))
12 12
13 13 ((* set parentdocumentclass = 'report' *))
14 14 ((* set documentclass = 'manual' *))
@@ -27,7 +27,7 b' consider calling super even if it is a leave block, we might insert more blocks '
27 27 {%- for worksheet in nb.worksheets -%}
28 28 {%- for cell in worksheet.cells -%}
29 29 {%- block any_cell scoped -%}
30 {%- if cell.type in ['code'] -%}
30 {%- if cell.cell_type in ['code'] -%}
31 31 {%- block codecell scoped -%}
32 32 {%- block input_group -%}
33 33 {%- block in_prompt -%}{%- endblock in_prompt -%}
@@ -69,13 +69,13 b' consider calling super even if it is a leave block, we might insert more blocks '
69 69 {%- endblock output_group -%}
70 70 {%- endif -%}
71 71 {%- endblock codecell -%}
72 {%- elif cell.type in ['markdown'] -%}
72 {%- elif cell.cell_type in ['markdown'] -%}
73 73 {%- block markdowncell scoped-%}
74 74 {%- endblock markdowncell -%}
75 {%- elif cell.type in ['heading'] -%}
75 {%- elif cell.cell_type in ['heading'] -%}
76 76 {%- block headingcell scoped-%}
77 77 {%- endblock headingcell -%}
78 {%- elif cell.type in ['raw'] -%}
78 {%- elif cell.cell_type in ['raw'] -%}
79 79 {%- block rawcell scoped-%}
80 80 {%- endblock rawcell -%}
81 81 {%- else -%}
@@ -10,7 +10,7 b' class ActivatableTransformer(ConfigurableTransformer):'
10 10 c.YourTransformerName.enabled = True
11 11 """
12 12
13 enabled = Bool(False, config=True)
13 enabled = Bool(True, config=True)
14 14
15 15 def __call__(self, nb, other):
16 16 if not self.enabled :
General Comments 0
You need to be logged in to leave comments. Login now