Show More
@@ -5,3 +5,4 b" c.ConverterTemplate.template_file='latex_base'" | |||||
5 | c.ConverterTemplate.tex_environement=True |
|
5 | c.ConverterTemplate.tex_environement=True | |
6 |
|
6 | |||
7 | c.ExtractFigureTransformer.extra_ext_map={'svg':'pdf'} |
|
7 | c.ExtractFigureTransformer.extra_ext_map={'svg':'pdf'} | |
|
8 | c.ExtractFigureTransformer.enabled=True |
@@ -1,4 +1,17 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
|
2 | """ | |||
|
3 | ================================================================================ | |||
|
4 | ||||
|
5 | |,---. | | , .| | | |||
|
6 | ||---', .|--- |---.,---.,---. |\ ||---.,---.,---.,---.. ,,---.,---.|--- | |||
|
7 | || | || | || || | | \ || || | || | \ / |---'| | | |||
|
8 | `` `---|`---'` '`---'` ' ` `'`---'`---'`---'` ' `' `---'` `---' | |||
|
9 | `---' | |||
|
10 | ================================================================================ | |||
|
11 | ||||
|
12 | Highly experimental for now | |||
|
13 | ||||
|
14 | """ | |||
2 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
3 | # Imports |
|
16 | # Imports | |
4 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- | |
@@ -22,6 +35,21 b' from converters.transformers import (ConfigurableTransformers,Foobar,ExtractFigu' | |||||
22 |
|
35 | |||
23 | class NbconvertApp(Application): |
|
36 | class NbconvertApp(Application): | |
24 |
|
37 | |||
|
38 | stdout = Bool(True, config=True) | |||
|
39 | write = Bool(False, config=True) | |||
|
40 | ||||
|
41 | aliases = { | |||
|
42 | 'stdout':'NbconvertApp.stdout', | |||
|
43 | 'write':'NbconvertApp.write', | |||
|
44 | } | |||
|
45 | ||||
|
46 | flags= {} | |||
|
47 | flags['no-stdout'] = ( | |||
|
48 | {'NbconvertApp' : {'stdout' : False}}, | |||
|
49 | """the doc for this flag | |||
|
50 | ||||
|
51 | """ | |||
|
52 | ) | |||
25 |
|
53 | |||
26 | def __init__(self, **kwargs): |
|
54 | def __init__(self, **kwargs): | |
27 | super(NbconvertApp, self).__init__(**kwargs) |
|
55 | super(NbconvertApp, self).__init__(**kwargs) | |
@@ -64,11 +92,21 b' class NbconvertApp(Application):' | |||||
64 | C.read(ipynb_file) |
|
92 | C.read(ipynb_file) | |
65 |
|
93 | |||
66 | output,resources = C.convert() |
|
94 | output,resources = C.convert() | |
67 |
|
95 | if self.stdout : | ||
68 | print(output.encode('utf-8')) |
|
96 | print(output.encode('utf-8')) | |
69 |
|
97 | |||
|
98 | out_root = ipynb_file[:-6].replace('.','_') | |||
|
99 | ||||
70 | keys = resources.keys() |
|
100 | keys = resources.keys() | |
71 | if keys : |
|
101 | if keys : | |
|
102 | if self.write : | |||
|
103 | os.mkdir(out_root) | |||
|
104 | for key in keys: | |||
|
105 | if self.write: | |||
|
106 | with io.open(os.path.join(out_root+key),'w') as f: | |||
|
107 | print(' writing to ',os.path.join(out_root+key)) | |||
|
108 | f.write(resources[key]) | |||
|
109 | if self.stdout: | |||
72 | print(''' |
|
110 | print(''' | |
73 | ====================== Keys in Resources ================================== |
|
111 | ====================== Keys in Resources ================================== | |
74 | ''') |
|
112 | ''') | |
@@ -83,6 +121,7 b' they need to be.' | |||||
83 | def main(): |
|
121 | def main(): | |
84 | """Convert a notebook to html in one step""" |
|
122 | """Convert a notebook to html in one step""" | |
85 | app = NbconvertApp.instance() |
|
123 | app = NbconvertApp.instance() | |
|
124 | app.description = __doc__ | |||
86 | app.initialize() |
|
125 | app.initialize() | |
87 | app.start() |
|
126 | app.start() | |
88 | app.run() |
|
127 | app.run() |
General Comments 0
You need to be logged in to leave comments.
Login now