Show More
@@ -13,14 +13,6 b' they are converted.' | |||||
13 |
|
13 | |||
14 | from .exporter import Exporter |
|
14 | from .exporter import Exporter | |
15 |
|
15 | |||
16 | from .html import HtmlExporter |
|
|||
17 | from .latex import LatexExporter |
|
|||
18 | from .markdown import MarkdownExporter |
|
|||
19 | from .python import PythonExporter |
|
|||
20 | from .reveal import RevealExporter |
|
|||
21 | from .rst import RstExporter |
|
|||
22 | from .sphinx import SphinxExporter |
|
|||
23 |
|
||||
24 | from IPython.nbformat.v3.nbbase import NotebookNode |
|
16 | from IPython.nbformat.v3.nbbase import NotebookNode | |
25 |
|
17 | |||
26 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
@@ -50,35 +42,10 b' def export(nb, config=None, transformers=None, filters=None, exporter_type=Expor' | |||||
50 | output, resources = exporter_instance.from_file(nb) |
|
42 | output, resources = exporter_instance.from_file(nb) | |
51 | return output, resources, exporter_instance |
|
43 | return output, resources, exporter_instance | |
52 |
|
44 | |||
53 |
|
45 | def load_class(template_name): | ||
54 | def export_sphinx(nb, config=None, transformers=None, filters=None): |
|
46 | class_name = template_name[0].upper() + template_name[1:] + "Exporter" | |
55 | return export(nb, config, transformers, filters, SphinxExporter) |
|
47 | module = __import__('nbconvert.api.' + template_name, fromlist=[class_name]) | |
56 |
|
48 | return getattr(module, class_name) | ||
57 | def export_html(nb, config=None, transformers=None, filters=None): |
|
|||
58 | return export(nb, config, transformers, filters, HtmlExporter) |
|
|||
59 |
|
||||
60 | def export_latex(nb, config=None, transformers=None, filters=None): |
|
|||
61 | return export(nb, config, transformers, filters, LatexExporter) |
|
|||
62 |
|
||||
63 | def export_markdown(nb, config=None, transformers=None, filters=None): |
|
|||
64 | return export(nb, config, transformers, filters, MarkdownExporter) |
|
|||
65 |
|
||||
66 | def export_python(nb, config=None, transformers=None, filters=None): |
|
|||
67 | return export(nb, config, transformers, filters, PythonExporter) |
|
|||
68 |
|
||||
69 | def export_reveal(nb, config=None, transformers=None, filters=None): |
|
|||
70 | return export(nb, config, transformers, filters, RevealExporter) |
|
|||
71 |
|
||||
72 | def export_rst(nb, config=None, transformers=None, filters=None): |
|
|||
73 | return export(nb, config, transformers, filters, RstExporter) |
|
|||
74 |
|
||||
75 | EXPORT_FUNCTIONS = {"sphinx": export_sphinx, |
|
|||
76 | "html": export_html, |
|
|||
77 | "latex": export_latex, |
|
|||
78 | "markdown": export_markdown, |
|
|||
79 | "python": export_python, |
|
|||
80 | "reveal": export_reveal, |
|
|||
81 | "rst": export_rst} |
|
|||
82 |
|
49 | |||
83 | def export_by_name(nb, template_name, config=None, transformers=None, filters=None): |
|
50 | def export_by_name(nb, template_name, config=None, transformers=None, filters=None): | |
84 |
return |
|
51 | return export(nb, config, transformers, filters, load_class(template_name)) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now