Show More
@@ -0,0 +1,5 b'' | |||||
|
1 | c = get_config() | |||
|
2 | ||||
|
3 | c.ConverterTemplate.extract_figures=False | |||
|
4 | c.ConverterTemplate.template_file='fullhtml' | |||
|
5 | c.ConverterTemplate.tex_environement=False |
@@ -0,0 +1,5 b'' | |||||
|
1 | c = get_config() | |||
|
2 | ||||
|
3 | c.ConverterTemplate.extract_figures=False | |||
|
4 | c.ConverterTemplate.template_file='latex_base' | |||
|
5 | c.ConverterTemplate.tex_environement=True |
@@ -207,6 +207,14 b' class ConverterTemplate(Configurable):' | |||||
207 | dictionnary |
|
207 | dictionnary | |
208 | """ |
|
208 | """ | |
209 | ) |
|
209 | ) | |
|
210 | ||||
|
211 | tex_environement = Bool(False, | |||
|
212 | config=True, | |||
|
213 | help=""" is this a tex environment or not """) | |||
|
214 | ||||
|
215 | template_file = Unicode('', | |||
|
216 | config=True, | |||
|
217 | help=""" whetever """ ) | |||
210 | #------------------------------------------------------------------------- |
|
218 | #------------------------------------------------------------------------- | |
211 | # Instance-level attributes that are set in the constructor for this |
|
219 | # Instance-level attributes that are set in the constructor for this | |
212 | # class. |
|
220 | # class. | |
@@ -221,7 +229,7 b' class ConverterTemplate(Configurable):' | |||||
221 | if fmt in output: |
|
229 | if fmt in output: | |
222 | return [fmt] |
|
230 | return [fmt] | |
223 |
|
231 | |||
224 |
def __init__(self |
|
232 | def __init__(self, preprocessors=[], config=None, **kw): | |
225 | """ |
|
233 | """ | |
226 | tplfile : jinja template file to process. |
|
234 | tplfile : jinja template file to process. | |
227 |
|
235 | |||
@@ -232,8 +240,8 b' class ConverterTemplate(Configurable):' | |||||
232 |
|
240 | |||
233 | """ |
|
241 | """ | |
234 | super(ConverterTemplate, self).__init__(config=config, **kw) |
|
242 | super(ConverterTemplate, self).__init__(config=config, **kw) | |
235 | self.env = texenv if tex_environement else env |
|
243 | self.env = texenv if self.tex_environement else env | |
236 | self.ext = '.tplx' if tex_environement else '.tpl' |
|
244 | self.ext = '.tplx' if self.tex_environement else '.tpl' | |
237 | self.nb = None |
|
245 | self.nb = None | |
238 | self.preprocessors = preprocessors |
|
246 | self.preprocessors = preprocessors | |
239 | self.preprocessors.append(haspyout_transformer) |
|
247 | self.preprocessors.append(haspyout_transformer) | |
@@ -250,7 +258,7 b' class ConverterTemplate(Configurable):' | |||||
250 | self.env.filters['ansi2html'] = ansi2html |
|
258 | self.env.filters['ansi2html'] = ansi2html | |
251 | self.env.filters['markdown2latex'] = markdown2latex |
|
259 | self.env.filters['markdown2latex'] = markdown2latex | |
252 |
|
260 | |||
253 | self.template = self.env.get_template(tplfile+self.ext) |
|
261 | self.template = self.env.get_template(self.template_file+self.ext) | |
254 |
|
262 | |||
255 |
|
263 | |||
256 |
|
264 |
@@ -5,6 +5,7 b'' | |||||
5 | from __future__ import print_function |
|
5 | from __future__ import print_function | |
6 | import sys |
|
6 | import sys | |
7 | import io |
|
7 | import io | |
|
8 | import os | |||
8 |
|
9 | |||
9 | from converters.template import * |
|
10 | from converters.template import * | |
10 | from converters.template import ConverterTemplate |
|
11 | from converters.template import ConverterTemplate | |
@@ -13,6 +14,7 b' from converters.html import ConverterHTML' | |||||
13 |
|
14 | |||
14 | # All the stuff needed for the configurable things |
|
15 | # All the stuff needed for the configurable things | |
15 | from IPython.config.application import Application |
|
16 | from IPython.config.application import Application | |
|
17 | from IPython.config.loader import ConfigFileNotFound | |||
16 | from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, CaselessStrEnum |
|
18 | from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, CaselessStrEnum | |
17 |
|
19 | |||
18 |
|
20 | |||
@@ -24,10 +26,23 b' class NbconvertApp(Application):' | |||||
24 | self.classes.insert(0,ConverterTemplate) |
|
26 | self.classes.insert(0,ConverterTemplate) | |
25 | # ensure those are registerd |
|
27 | # ensure those are registerd | |
26 |
|
28 | |||
|
29 | def load_config_file(self, profile_name): | |||
|
30 | try: | |||
|
31 | Application.load_config_file( | |||
|
32 | self, | |||
|
33 | profile_name+'.nbcv', | |||
|
34 | path=[os.path.join(os.getcwdu(),'profile')] | |||
|
35 | ) | |||
|
36 | except ConfigFileNotFound: | |||
|
37 | self.log.warn("Config file for profile '%s' not found, giving up ",profile_name) | |||
|
38 | exit(1) | |||
|
39 | ||||
27 |
|
40 | |||
28 | def initialize(self, argv=None): |
|
41 | def initialize(self, argv=None): | |
29 | self.parse_command_line(argv) |
|
42 | self.parse_command_line(argv) | |
30 | cl_config = self.config |
|
43 | cl_config = self.config | |
|
44 | profile_file = sys.argv[1] | |||
|
45 | self.load_config_file(profile_file) | |||
31 | self.update_config(cl_config) |
|
46 | self.update_config(cl_config) | |
32 |
|
47 | |||
33 |
|
48 | |||
@@ -45,7 +60,6 b' class NbconvertApp(Application):' | |||||
45 | tex_environement=False |
|
60 | tex_environement=False | |
46 |
|
61 | |||
47 | C = ConverterTemplate(tplfile=sys.argv[1], |
|
62 | C = ConverterTemplate(tplfile=sys.argv[1], | |
48 | tex_environement=tex_environement, |
|
|||
49 | config=self.config) |
|
63 | config=self.config) | |
50 | C.read(ipynb_file) |
|
64 | C.read(ipynb_file) | |
51 |
|
65 |
General Comments 0
You need to be logged in to leave comments.
Login now