Show More
@@ -1,312 +1,313 b'' | |||||
1 | """This module defines Exporter, a highly configurable converter |
|
1 | """This module defines Exporter, a highly configurable converter | |
2 | that uses Jinja2 to export notebook files into different formats. |
|
2 | that uses Jinja2 to export notebook files into different formats. | |
3 | """ |
|
3 | """ | |
4 |
|
4 | |||
5 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- | |
6 | # Copyright (c) 2013, the IPython Development Team. |
|
6 | # Copyright (c) 2013, the IPython Development Team. | |
7 | # |
|
7 | # | |
8 | # Distributed under the terms of the Modified BSD License. |
|
8 | # Distributed under the terms of the Modified BSD License. | |
9 | # |
|
9 | # | |
10 | # The full license is in the file COPYING.txt, distributed with this software. |
|
10 | # The full license is in the file COPYING.txt, distributed with this software. | |
11 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
12 |
|
12 | |||
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 |
|
16 | |||
17 | from __future__ import print_function, absolute_import |
|
17 | from __future__ import print_function, absolute_import | |
18 |
|
18 | |||
19 | # Stdlib imports |
|
19 | # Stdlib imports | |
20 | import os |
|
20 | import os | |
21 |
|
21 | |||
22 | # other libs/dependencies |
|
22 | # other libs/dependencies | |
23 | from jinja2 import Environment, FileSystemLoader, ChoiceLoader, TemplateNotFound |
|
23 | from jinja2 import Environment, FileSystemLoader, ChoiceLoader, TemplateNotFound | |
24 |
|
24 | |||
25 | # IPython imports |
|
25 | # IPython imports | |
26 | from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Dict, Any |
|
26 | from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Dict, Any | |
27 | from IPython.utils.importstring import import_item |
|
27 | from IPython.utils.importstring import import_item | |
28 | from IPython.utils import py3compat, text |
|
28 | from IPython.utils import py3compat, text | |
29 |
|
29 | |||
30 | from IPython.nbconvert import filters |
|
30 | from IPython.nbconvert import filters | |
31 | from .exporter import Exporter |
|
31 | from .exporter import Exporter | |
32 |
|
32 | |||
33 | #----------------------------------------------------------------------------- |
|
33 | #----------------------------------------------------------------------------- | |
34 | # Globals and constants |
|
34 | # Globals and constants | |
35 | #----------------------------------------------------------------------------- |
|
35 | #----------------------------------------------------------------------------- | |
36 |
|
36 | |||
37 | #Jinja2 extensions to load. |
|
37 | #Jinja2 extensions to load. | |
38 | JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols'] |
|
38 | JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols'] | |
39 |
|
39 | |||
40 | default_filters = { |
|
40 | default_filters = { | |
41 | 'indent': text.indent, |
|
41 | 'indent': text.indent, | |
42 | 'markdown2html': filters.markdown2html, |
|
42 | 'markdown2html': filters.markdown2html, | |
43 | 'ansi2html': filters.ansi2html, |
|
43 | 'ansi2html': filters.ansi2html, | |
44 | 'filter_data_type': filters.DataTypeFilter, |
|
44 | 'filter_data_type': filters.DataTypeFilter, | |
45 | 'get_lines': filters.get_lines, |
|
45 | 'get_lines': filters.get_lines, | |
46 | 'highlight2html': filters.Highlight2Html, |
|
46 | 'highlight2html': filters.Highlight2Html, | |
47 | 'highlight2latex': filters.Highlight2Latex, |
|
47 | 'highlight2latex': filters.Highlight2Latex, | |
48 | 'ipython2python': filters.ipython2python, |
|
48 | 'ipython2python': filters.ipython2python, | |
49 | 'posix_path': filters.posix_path, |
|
49 | 'posix_path': filters.posix_path, | |
50 | 'markdown2latex': filters.markdown2latex, |
|
50 | 'markdown2latex': filters.markdown2latex, | |
51 | 'markdown2rst': filters.markdown2rst, |
|
51 | 'markdown2rst': filters.markdown2rst, | |
52 | 'comment_lines': filters.comment_lines, |
|
52 | 'comment_lines': filters.comment_lines, | |
53 | 'strip_ansi': filters.strip_ansi, |
|
53 | 'strip_ansi': filters.strip_ansi, | |
54 | 'strip_dollars': filters.strip_dollars, |
|
54 | 'strip_dollars': filters.strip_dollars, | |
55 | 'strip_files_prefix': filters.strip_files_prefix, |
|
55 | 'strip_files_prefix': filters.strip_files_prefix, | |
56 | 'html2text' : filters.html2text, |
|
56 | 'html2text' : filters.html2text, | |
57 | 'add_anchor': filters.add_anchor, |
|
57 | 'add_anchor': filters.add_anchor, | |
58 | 'ansi2latex': filters.ansi2latex, |
|
58 | 'ansi2latex': filters.ansi2latex, | |
59 | 'wrap_text': filters.wrap_text, |
|
59 | 'wrap_text': filters.wrap_text, | |
60 | 'escape_latex': filters.escape_latex, |
|
60 | 'escape_latex': filters.escape_latex, | |
61 | 'citation2latex': filters.citation2latex, |
|
61 | 'citation2latex': filters.citation2latex, | |
62 | 'path2url': filters.path2url, |
|
62 | 'path2url': filters.path2url, | |
63 | 'add_prompts': filters.add_prompts, |
|
63 | 'add_prompts': filters.add_prompts, | |
|
64 | 'strip_url_static_file_prefix': filters.strip_url_static_file_prefix, | |||
64 | } |
|
65 | } | |
65 |
|
66 | |||
66 | #----------------------------------------------------------------------------- |
|
67 | #----------------------------------------------------------------------------- | |
67 | # Class |
|
68 | # Class | |
68 | #----------------------------------------------------------------------------- |
|
69 | #----------------------------------------------------------------------------- | |
69 |
|
70 | |||
70 | class TemplateExporter(Exporter): |
|
71 | class TemplateExporter(Exporter): | |
71 | """ |
|
72 | """ | |
72 | Exports notebooks into other file formats. Uses Jinja 2 templating engine |
|
73 | Exports notebooks into other file formats. Uses Jinja 2 templating engine | |
73 | to output new formats. Inherit from this class if you are creating a new |
|
74 | to output new formats. Inherit from this class if you are creating a new | |
74 | template type along with new filters/preprocessors. If the filters/ |
|
75 | template type along with new filters/preprocessors. If the filters/ | |
75 | preprocessors provided by default suffice, there is no need to inherit from |
|
76 | preprocessors provided by default suffice, there is no need to inherit from | |
76 | this class. Instead, override the template_file and file_extension |
|
77 | this class. Instead, override the template_file and file_extension | |
77 | traits via a config file. |
|
78 | traits via a config file. | |
78 |
|
79 | |||
79 | {filters} |
|
80 | {filters} | |
80 | """ |
|
81 | """ | |
81 |
|
82 | |||
82 | # finish the docstring |
|
83 | # finish the docstring | |
83 | __doc__ = __doc__.format(filters = '- '+'\n - '.join(default_filters.keys())) |
|
84 | __doc__ = __doc__.format(filters = '- '+'\n - '.join(default_filters.keys())) | |
84 |
|
85 | |||
85 |
|
86 | |||
86 | template_file = Unicode(u'default', |
|
87 | template_file = Unicode(u'default', | |
87 | config=True, |
|
88 | config=True, | |
88 | help="Name of the template file to use") |
|
89 | help="Name of the template file to use") | |
89 | def _template_file_changed(self, name, old, new): |
|
90 | def _template_file_changed(self, name, old, new): | |
90 | if new == 'default': |
|
91 | if new == 'default': | |
91 | self.template_file = self.default_template |
|
92 | self.template_file = self.default_template | |
92 | else: |
|
93 | else: | |
93 | self.template_file = new |
|
94 | self.template_file = new | |
94 | self.template = None |
|
95 | self.template = None | |
95 | self._load_template() |
|
96 | self._load_template() | |
96 |
|
97 | |||
97 | default_template = Unicode(u'') |
|
98 | default_template = Unicode(u'') | |
98 | template = Any() |
|
99 | template = Any() | |
99 | environment = Any() |
|
100 | environment = Any() | |
100 |
|
101 | |||
101 | template_path = List(['.'], config=True) |
|
102 | template_path = List(['.'], config=True) | |
102 | def _template_path_changed(self, name, old, new): |
|
103 | def _template_path_changed(self, name, old, new): | |
103 | self._load_template() |
|
104 | self._load_template() | |
104 |
|
105 | |||
105 | default_template_path = Unicode( |
|
106 | default_template_path = Unicode( | |
106 | os.path.join("..", "templates"), |
|
107 | os.path.join("..", "templates"), | |
107 | help="Path where the template files are located.") |
|
108 | help="Path where the template files are located.") | |
108 |
|
109 | |||
109 | template_skeleton_path = Unicode( |
|
110 | template_skeleton_path = Unicode( | |
110 | os.path.join("..", "templates", "skeleton"), |
|
111 | os.path.join("..", "templates", "skeleton"), | |
111 | help="Path where the template skeleton files are located.") |
|
112 | help="Path where the template skeleton files are located.") | |
112 |
|
113 | |||
113 | #Jinja block definitions |
|
114 | #Jinja block definitions | |
114 | jinja_comment_block_start = Unicode("", config=True) |
|
115 | jinja_comment_block_start = Unicode("", config=True) | |
115 | jinja_comment_block_end = Unicode("", config=True) |
|
116 | jinja_comment_block_end = Unicode("", config=True) | |
116 | jinja_variable_block_start = Unicode("", config=True) |
|
117 | jinja_variable_block_start = Unicode("", config=True) | |
117 | jinja_variable_block_end = Unicode("", config=True) |
|
118 | jinja_variable_block_end = Unicode("", config=True) | |
118 | jinja_logic_block_start = Unicode("", config=True) |
|
119 | jinja_logic_block_start = Unicode("", config=True) | |
119 | jinja_logic_block_end = Unicode("", config=True) |
|
120 | jinja_logic_block_end = Unicode("", config=True) | |
120 |
|
121 | |||
121 | #Extension that the template files use. |
|
122 | #Extension that the template files use. | |
122 | template_extension = Unicode(".tpl", config=True) |
|
123 | template_extension = Unicode(".tpl", config=True) | |
123 |
|
124 | |||
124 | filters = Dict(config=True, |
|
125 | filters = Dict(config=True, | |
125 | help="""Dictionary of filters, by name and namespace, to add to the Jinja |
|
126 | help="""Dictionary of filters, by name and namespace, to add to the Jinja | |
126 | environment.""") |
|
127 | environment.""") | |
127 |
|
128 | |||
128 |
|
129 | |||
129 | def __init__(self, config=None, extra_loaders=None, **kw): |
|
130 | def __init__(self, config=None, extra_loaders=None, **kw): | |
130 | """ |
|
131 | """ | |
131 | Public constructor |
|
132 | Public constructor | |
132 |
|
133 | |||
133 | Parameters |
|
134 | Parameters | |
134 | ---------- |
|
135 | ---------- | |
135 | config : config |
|
136 | config : config | |
136 | User configuration instance. |
|
137 | User configuration instance. | |
137 | extra_loaders : list[of Jinja Loaders] |
|
138 | extra_loaders : list[of Jinja Loaders] | |
138 | ordered list of Jinja loader to find templates. Will be tried in order |
|
139 | ordered list of Jinja loader to find templates. Will be tried in order | |
139 | before the default FileSystem ones. |
|
140 | before the default FileSystem ones. | |
140 | template : str (optional, kw arg) |
|
141 | template : str (optional, kw arg) | |
141 | Template to use when exporting. |
|
142 | Template to use when exporting. | |
142 | """ |
|
143 | """ | |
143 | super(TemplateExporter, self).__init__(config=config, **kw) |
|
144 | super(TemplateExporter, self).__init__(config=config, **kw) | |
144 |
|
145 | |||
145 | #Init |
|
146 | #Init | |
146 | self._init_template() |
|
147 | self._init_template() | |
147 | self._init_environment(extra_loaders=extra_loaders) |
|
148 | self._init_environment(extra_loaders=extra_loaders) | |
148 | self._init_preprocessors() |
|
149 | self._init_preprocessors() | |
149 | self._init_filters() |
|
150 | self._init_filters() | |
150 |
|
151 | |||
151 |
|
152 | |||
152 | def _load_template(self): |
|
153 | def _load_template(self): | |
153 | """Load the Jinja template object from the template file |
|
154 | """Load the Jinja template object from the template file | |
154 |
|
155 | |||
155 | This is a no-op if the template attribute is already defined, |
|
156 | This is a no-op if the template attribute is already defined, | |
156 | or the Jinja environment is not setup yet. |
|
157 | or the Jinja environment is not setup yet. | |
157 |
|
158 | |||
158 | This is triggered by various trait changes that would change the template. |
|
159 | This is triggered by various trait changes that would change the template. | |
159 | """ |
|
160 | """ | |
160 | if self.template is not None: |
|
161 | if self.template is not None: | |
161 | return |
|
162 | return | |
162 | # called too early, do nothing |
|
163 | # called too early, do nothing | |
163 | if self.environment is None: |
|
164 | if self.environment is None: | |
164 | return |
|
165 | return | |
165 | # Try different template names during conversion. First try to load the |
|
166 | # Try different template names during conversion. First try to load the | |
166 | # template by name with extension added, then try loading the template |
|
167 | # template by name with extension added, then try loading the template | |
167 | # as if the name is explicitly specified, then try the name as a |
|
168 | # as if the name is explicitly specified, then try the name as a | |
168 | # 'flavor', and lastly just try to load the template by module name. |
|
169 | # 'flavor', and lastly just try to load the template by module name. | |
169 | module_name = self.__module__.rsplit('.', 1)[-1] |
|
170 | module_name = self.__module__.rsplit('.', 1)[-1] | |
170 | try_names = [] |
|
171 | try_names = [] | |
171 | if self.template_file: |
|
172 | if self.template_file: | |
172 | try_names.extend([ |
|
173 | try_names.extend([ | |
173 | self.template_file + self.template_extension, |
|
174 | self.template_file + self.template_extension, | |
174 | self.template_file, |
|
175 | self.template_file, | |
175 | module_name + '_' + self.template_file + self.template_extension, |
|
176 | module_name + '_' + self.template_file + self.template_extension, | |
176 | ]) |
|
177 | ]) | |
177 | try_names.append(module_name + self.template_extension) |
|
178 | try_names.append(module_name + self.template_extension) | |
178 | for try_name in try_names: |
|
179 | for try_name in try_names: | |
179 | self.log.debug("Attempting to load template %s", try_name) |
|
180 | self.log.debug("Attempting to load template %s", try_name) | |
180 | try: |
|
181 | try: | |
181 | self.template = self.environment.get_template(try_name) |
|
182 | self.template = self.environment.get_template(try_name) | |
182 | except (TemplateNotFound, IOError): |
|
183 | except (TemplateNotFound, IOError): | |
183 | pass |
|
184 | pass | |
184 | except Exception as e: |
|
185 | except Exception as e: | |
185 | self.log.warn("Unexpected exception loading template: %s", try_name, exc_info=True) |
|
186 | self.log.warn("Unexpected exception loading template: %s", try_name, exc_info=True) | |
186 | else: |
|
187 | else: | |
187 | self.log.info("Loaded template %s", try_name) |
|
188 | self.log.info("Loaded template %s", try_name) | |
188 | break |
|
189 | break | |
189 |
|
190 | |||
190 | def from_notebook_node(self, nb, resources=None, **kw): |
|
191 | def from_notebook_node(self, nb, resources=None, **kw): | |
191 | """ |
|
192 | """ | |
192 | Convert a notebook from a notebook node instance. |
|
193 | Convert a notebook from a notebook node instance. | |
193 |
|
194 | |||
194 | Parameters |
|
195 | Parameters | |
195 | ---------- |
|
196 | ---------- | |
196 | nb : Notebook node |
|
197 | nb : Notebook node | |
197 | resources : dict (**kw) |
|
198 | resources : dict (**kw) | |
198 | of additional resources that can be accessed read/write by |
|
199 | of additional resources that can be accessed read/write by | |
199 | preprocessors and filters. |
|
200 | preprocessors and filters. | |
200 | """ |
|
201 | """ | |
201 | nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) |
|
202 | nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) | |
202 |
|
203 | |||
203 | self._load_template() |
|
204 | self._load_template() | |
204 |
|
205 | |||
205 | if self.template is not None: |
|
206 | if self.template is not None: | |
206 | output = self.template.render(nb=nb_copy, resources=resources) |
|
207 | output = self.template.render(nb=nb_copy, resources=resources) | |
207 | else: |
|
208 | else: | |
208 | raise IOError('template file "%s" could not be found' % self.template_file) |
|
209 | raise IOError('template file "%s" could not be found' % self.template_file) | |
209 | return output, resources |
|
210 | return output, resources | |
210 |
|
211 | |||
211 |
|
212 | |||
212 | def register_filter(self, name, jinja_filter): |
|
213 | def register_filter(self, name, jinja_filter): | |
213 | """ |
|
214 | """ | |
214 | Register a filter. |
|
215 | Register a filter. | |
215 | A filter is a function that accepts and acts on one string. |
|
216 | A filter is a function that accepts and acts on one string. | |
216 | The filters are accesible within the Jinja templating engine. |
|
217 | The filters are accesible within the Jinja templating engine. | |
217 |
|
218 | |||
218 | Parameters |
|
219 | Parameters | |
219 | ---------- |
|
220 | ---------- | |
220 | name : str |
|
221 | name : str | |
221 | name to give the filter in the Jinja engine |
|
222 | name to give the filter in the Jinja engine | |
222 | filter : filter |
|
223 | filter : filter | |
223 | """ |
|
224 | """ | |
224 | if jinja_filter is None: |
|
225 | if jinja_filter is None: | |
225 | raise TypeError('filter') |
|
226 | raise TypeError('filter') | |
226 | isclass = isinstance(jinja_filter, type) |
|
227 | isclass = isinstance(jinja_filter, type) | |
227 | constructed = not isclass |
|
228 | constructed = not isclass | |
228 |
|
229 | |||
229 | #Handle filter's registration based on it's type |
|
230 | #Handle filter's registration based on it's type | |
230 | if constructed and isinstance(jinja_filter, py3compat.string_types): |
|
231 | if constructed and isinstance(jinja_filter, py3compat.string_types): | |
231 | #filter is a string, import the namespace and recursively call |
|
232 | #filter is a string, import the namespace and recursively call | |
232 | #this register_filter method |
|
233 | #this register_filter method | |
233 | filter_cls = import_item(jinja_filter) |
|
234 | filter_cls = import_item(jinja_filter) | |
234 | return self.register_filter(name, filter_cls) |
|
235 | return self.register_filter(name, filter_cls) | |
235 |
|
236 | |||
236 | if constructed and hasattr(jinja_filter, '__call__'): |
|
237 | if constructed and hasattr(jinja_filter, '__call__'): | |
237 | #filter is a function, no need to construct it. |
|
238 | #filter is a function, no need to construct it. | |
238 | self.environment.filters[name] = jinja_filter |
|
239 | self.environment.filters[name] = jinja_filter | |
239 | return jinja_filter |
|
240 | return jinja_filter | |
240 |
|
241 | |||
241 | elif isclass and isinstance(jinja_filter, MetaHasTraits): |
|
242 | elif isclass and isinstance(jinja_filter, MetaHasTraits): | |
242 | #filter is configurable. Make sure to pass in new default for |
|
243 | #filter is configurable. Make sure to pass in new default for | |
243 | #the enabled flag if one was specified. |
|
244 | #the enabled flag if one was specified. | |
244 | filter_instance = jinja_filter(parent=self) |
|
245 | filter_instance = jinja_filter(parent=self) | |
245 | self.register_filter(name, filter_instance ) |
|
246 | self.register_filter(name, filter_instance ) | |
246 |
|
247 | |||
247 | elif isclass: |
|
248 | elif isclass: | |
248 | #filter is not configurable, construct it |
|
249 | #filter is not configurable, construct it | |
249 | filter_instance = jinja_filter() |
|
250 | filter_instance = jinja_filter() | |
250 | self.register_filter(name, filter_instance) |
|
251 | self.register_filter(name, filter_instance) | |
251 |
|
252 | |||
252 | else: |
|
253 | else: | |
253 | #filter is an instance of something without a __call__ |
|
254 | #filter is an instance of something without a __call__ | |
254 | #attribute. |
|
255 | #attribute. | |
255 | raise TypeError('filter') |
|
256 | raise TypeError('filter') | |
256 |
|
257 | |||
257 |
|
258 | |||
258 | def _init_template(self): |
|
259 | def _init_template(self): | |
259 | """ |
|
260 | """ | |
260 | Make sure a template name is specified. If one isn't specified, try to |
|
261 | Make sure a template name is specified. If one isn't specified, try to | |
261 | build one from the information we know. |
|
262 | build one from the information we know. | |
262 | """ |
|
263 | """ | |
263 | self._template_file_changed('template_file', self.template_file, self.template_file) |
|
264 | self._template_file_changed('template_file', self.template_file, self.template_file) | |
264 |
|
265 | |||
265 |
|
266 | |||
266 | def _init_environment(self, extra_loaders=None): |
|
267 | def _init_environment(self, extra_loaders=None): | |
267 | """ |
|
268 | """ | |
268 | Create the Jinja templating environment. |
|
269 | Create the Jinja templating environment. | |
269 | """ |
|
270 | """ | |
270 | here = os.path.dirname(os.path.realpath(__file__)) |
|
271 | here = os.path.dirname(os.path.realpath(__file__)) | |
271 | loaders = [] |
|
272 | loaders = [] | |
272 | if extra_loaders: |
|
273 | if extra_loaders: | |
273 | loaders.extend(extra_loaders) |
|
274 | loaders.extend(extra_loaders) | |
274 |
|
275 | |||
275 | paths = self.template_path |
|
276 | paths = self.template_path | |
276 | paths.extend([os.path.join(here, self.default_template_path), |
|
277 | paths.extend([os.path.join(here, self.default_template_path), | |
277 | os.path.join(here, self.template_skeleton_path)]) |
|
278 | os.path.join(here, self.template_skeleton_path)]) | |
278 | loaders.append(FileSystemLoader(paths)) |
|
279 | loaders.append(FileSystemLoader(paths)) | |
279 |
|
280 | |||
280 | self.environment = Environment( |
|
281 | self.environment = Environment( | |
281 | loader= ChoiceLoader(loaders), |
|
282 | loader= ChoiceLoader(loaders), | |
282 | extensions=JINJA_EXTENSIONS |
|
283 | extensions=JINJA_EXTENSIONS | |
283 | ) |
|
284 | ) | |
284 |
|
285 | |||
285 | #Set special Jinja2 syntax that will not conflict with latex. |
|
286 | #Set special Jinja2 syntax that will not conflict with latex. | |
286 | if self.jinja_logic_block_start: |
|
287 | if self.jinja_logic_block_start: | |
287 | self.environment.block_start_string = self.jinja_logic_block_start |
|
288 | self.environment.block_start_string = self.jinja_logic_block_start | |
288 | if self.jinja_logic_block_end: |
|
289 | if self.jinja_logic_block_end: | |
289 | self.environment.block_end_string = self.jinja_logic_block_end |
|
290 | self.environment.block_end_string = self.jinja_logic_block_end | |
290 | if self.jinja_variable_block_start: |
|
291 | if self.jinja_variable_block_start: | |
291 | self.environment.variable_start_string = self.jinja_variable_block_start |
|
292 | self.environment.variable_start_string = self.jinja_variable_block_start | |
292 | if self.jinja_variable_block_end: |
|
293 | if self.jinja_variable_block_end: | |
293 | self.environment.variable_end_string = self.jinja_variable_block_end |
|
294 | self.environment.variable_end_string = self.jinja_variable_block_end | |
294 | if self.jinja_comment_block_start: |
|
295 | if self.jinja_comment_block_start: | |
295 | self.environment.comment_start_string = self.jinja_comment_block_start |
|
296 | self.environment.comment_start_string = self.jinja_comment_block_start | |
296 | if self.jinja_comment_block_end: |
|
297 | if self.jinja_comment_block_end: | |
297 | self.environment.comment_end_string = self.jinja_comment_block_end |
|
298 | self.environment.comment_end_string = self.jinja_comment_block_end | |
298 |
|
299 | |||
299 |
|
300 | |||
300 | def _init_filters(self): |
|
301 | def _init_filters(self): | |
301 | """ |
|
302 | """ | |
302 | Register all of the filters required for the exporter. |
|
303 | Register all of the filters required for the exporter. | |
303 | """ |
|
304 | """ | |
304 |
|
305 | |||
305 | #Add default filters to the Jinja2 environment |
|
306 | #Add default filters to the Jinja2 environment | |
306 | for key, value in default_filters.items(): |
|
307 | for key, value in default_filters.items(): | |
307 | self.register_filter(key, value) |
|
308 | self.register_filter(key, value) | |
308 |
|
309 | |||
309 | #Load user filters. Overwrite existing filters if need be. |
|
310 | #Load user filters. Overwrite existing filters if need be. | |
310 | if self.filters: |
|
311 | if self.filters: | |
311 | for key, user_filter in self.filters.items(): |
|
312 | for key, user_filter in self.filters.items(): | |
312 | self.register_filter(key, user_filter) |
|
313 | self.register_filter(key, user_filter) |
@@ -1,228 +1,228 b'' | |||||
1 | ((= Latex base template (must inherit) |
|
1 | ((= Latex base template (must inherit) | |
2 | This template builds upon the abstract template, adding common latex output |
|
2 | This template builds upon the abstract template, adding common latex output | |
3 | functions. Figures, data_text, |
|
3 | functions. Figures, data_text, | |
4 | This template does not define a docclass, the inheriting class must define this.=)) |
|
4 | This template does not define a docclass, the inheriting class must define this.=)) | |
5 |
|
5 | |||
6 | ((*- extends 'display_priority.tplx' -*)) |
|
6 | ((*- extends 'display_priority.tplx' -*)) | |
7 |
|
7 | |||
8 | %=============================================================================== |
|
8 | %=============================================================================== | |
9 | % Abstract overrides |
|
9 | % Abstract overrides | |
10 | %=============================================================================== |
|
10 | %=============================================================================== | |
11 |
|
11 | |||
12 | ((* block header *)) |
|
12 | ((* block header *)) | |
13 | ((* block docclass *))((* endblock docclass *)) |
|
13 | ((* block docclass *))((* endblock docclass *)) | |
14 |
|
14 | |||
15 | ((* block packages *)) |
|
15 | ((* block packages *)) | |
16 | \usepackage{graphicx} % Used to insert images |
|
16 | \usepackage{graphicx} % Used to insert images | |
17 | \usepackage{adjustbox} % Used to constrain images to a maximum size |
|
17 | \usepackage{adjustbox} % Used to constrain images to a maximum size | |
18 | \usepackage{color} % Allow colors to be defined |
|
18 | \usepackage{color} % Allow colors to be defined | |
19 | \usepackage{enumerate} % Needed for markdown enumerations to work |
|
19 | \usepackage{enumerate} % Needed for markdown enumerations to work | |
20 | \usepackage{geometry} % Used to adjust the document margins |
|
20 | \usepackage{geometry} % Used to adjust the document margins | |
21 | \usepackage{amsmath} % Equations |
|
21 | \usepackage{amsmath} % Equations | |
22 | \usepackage{amssymb} % Equations |
|
22 | \usepackage{amssymb} % Equations | |
23 | \usepackage[utf8]{inputenc} % Allow utf-8 characters in the tex document |
|
23 | \usepackage[utf8]{inputenc} % Allow utf-8 characters in the tex document | |
24 | \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support |
|
24 | \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support | |
25 | \usepackage{fancyvrb} % verbatim replacement that allows latex |
|
25 | \usepackage{fancyvrb} % verbatim replacement that allows latex | |
26 | \usepackage{grffile} % extends the file name processing of package graphics |
|
26 | \usepackage{grffile} % extends the file name processing of package graphics | |
27 | % to support a larger range |
|
27 | % to support a larger range | |
28 | % The hyperref package gives us a pdf with properly built |
|
28 | % The hyperref package gives us a pdf with properly built | |
29 | % internal navigation ('pdf bookmarks' for the table of contents, |
|
29 | % internal navigation ('pdf bookmarks' for the table of contents, | |
30 | % internal cross-reference links, web links for URLs, etc.) |
|
30 | % internal cross-reference links, web links for URLs, etc.) | |
31 | \usepackage{hyperref} |
|
31 | \usepackage{hyperref} | |
32 | \usepackage{longtable} % longtable support required by pandoc >1.10 |
|
32 | \usepackage{longtable} % longtable support required by pandoc >1.10 | |
33 | ((* endblock packages *)) |
|
33 | ((* endblock packages *)) | |
34 |
|
34 | |||
35 | ((* block definitions *)) |
|
35 | ((* block definitions *)) | |
36 | \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
|
36 | \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} | |
37 | \definecolor{darkorange}{rgb}{.71,0.21,0.01} |
|
37 | \definecolor{darkorange}{rgb}{.71,0.21,0.01} | |
38 | \definecolor{darkgreen}{rgb}{.12,.54,.11} |
|
38 | \definecolor{darkgreen}{rgb}{.12,.54,.11} | |
39 | \definecolor{myteal}{rgb}{.26, .44, .56} |
|
39 | \definecolor{myteal}{rgb}{.26, .44, .56} | |
40 | \definecolor{gray}{gray}{0.45} |
|
40 | \definecolor{gray}{gray}{0.45} | |
41 | \definecolor{lightgray}{gray}{.95} |
|
41 | \definecolor{lightgray}{gray}{.95} | |
42 | \definecolor{mediumgray}{gray}{.8} |
|
42 | \definecolor{mediumgray}{gray}{.8} | |
43 | \definecolor{inputbackground}{rgb}{.95, .95, .85} |
|
43 | \definecolor{inputbackground}{rgb}{.95, .95, .85} | |
44 | \definecolor{outputbackground}{rgb}{.95, .95, .95} |
|
44 | \definecolor{outputbackground}{rgb}{.95, .95, .95} | |
45 | \definecolor{traceback}{rgb}{1, .95, .95} |
|
45 | \definecolor{traceback}{rgb}{1, .95, .95} | |
46 | % ansi colors |
|
46 | % ansi colors | |
47 | \definecolor{red}{rgb}{.6,0,0} |
|
47 | \definecolor{red}{rgb}{.6,0,0} | |
48 | \definecolor{green}{rgb}{0,.65,0} |
|
48 | \definecolor{green}{rgb}{0,.65,0} | |
49 | \definecolor{brown}{rgb}{0.6,0.6,0} |
|
49 | \definecolor{brown}{rgb}{0.6,0.6,0} | |
50 | \definecolor{blue}{rgb}{0,.145,.698} |
|
50 | \definecolor{blue}{rgb}{0,.145,.698} | |
51 | \definecolor{purple}{rgb}{.698,.145,.698} |
|
51 | \definecolor{purple}{rgb}{.698,.145,.698} | |
52 | \definecolor{cyan}{rgb}{0,.698,.698} |
|
52 | \definecolor{cyan}{rgb}{0,.698,.698} | |
53 | \definecolor{lightgray}{gray}{0.5} |
|
53 | \definecolor{lightgray}{gray}{0.5} | |
54 |
|
54 | |||
55 | % bright ansi colors |
|
55 | % bright ansi colors | |
56 | \definecolor{darkgray}{gray}{0.25} |
|
56 | \definecolor{darkgray}{gray}{0.25} | |
57 | \definecolor{lightred}{rgb}{1.0,0.39,0.28} |
|
57 | \definecolor{lightred}{rgb}{1.0,0.39,0.28} | |
58 | \definecolor{lightgreen}{rgb}{0.48,0.99,0.0} |
|
58 | \definecolor{lightgreen}{rgb}{0.48,0.99,0.0} | |
59 | \definecolor{lightblue}{rgb}{0.53,0.81,0.92} |
|
59 | \definecolor{lightblue}{rgb}{0.53,0.81,0.92} | |
60 | \definecolor{lightpurple}{rgb}{0.87,0.63,0.87} |
|
60 | \definecolor{lightpurple}{rgb}{0.87,0.63,0.87} | |
61 | \definecolor{lightcyan}{rgb}{0.5,1.0,0.83} |
|
61 | \definecolor{lightcyan}{rgb}{0.5,1.0,0.83} | |
62 |
|
62 | |||
63 | % commands and environments needed by pandoc snippets |
|
63 | % commands and environments needed by pandoc snippets | |
64 | % extracted from the output of `pandoc -s` |
|
64 | % extracted from the output of `pandoc -s` | |
65 |
|
65 | |||
66 | \DefineShortVerb[commandchars=\\\{\}]{\|} |
|
66 | \DefineShortVerb[commandchars=\\\{\}]{\|} | |
67 | \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} |
|
67 | \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} | |
68 | % Add ',fontsize=\small' for more characters per line |
|
68 | % Add ',fontsize=\small' for more characters per line | |
69 | \newenvironment{Shaded}{}{} |
|
69 | \newenvironment{Shaded}{}{} | |
70 | \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} |
|
70 | \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | |
71 | \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} |
|
71 | \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} | |
72 | \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} |
|
72 | \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
73 | \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} |
|
73 | \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
74 | \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} |
|
74 | \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
75 | \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} |
|
75 | \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
76 | \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} |
|
76 | \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
77 | \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} |
|
77 | \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} | |
78 | \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} |
|
78 | \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} | |
79 | \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} |
|
79 | \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |
80 | \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} |
|
80 | \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} | |
81 | \newcommand{\RegionMarkerTok}[1]{{#1}} |
|
81 | \newcommand{\RegionMarkerTok}[1]{{#1}} | |
82 | \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} |
|
82 | \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |
83 | \newcommand{\NormalTok}[1]{{#1}} |
|
83 | \newcommand{\NormalTok}[1]{{#1}} | |
84 |
|
84 | |||
85 | % Define a nice break command that doesn't care if a line doesn't already |
|
85 | % Define a nice break command that doesn't care if a line doesn't already | |
86 | % exist. |
|
86 | % exist. | |
87 | \def\br{\hspace*{\fill} \\* } |
|
87 | \def\br{\hspace*{\fill} \\* } | |
88 | % Math Jax compatability definitions |
|
88 | % Math Jax compatability definitions | |
89 | \def\gt{>} |
|
89 | \def\gt{>} | |
90 | \def\lt{<} |
|
90 | \def\lt{<} | |
91 | % Document parameters |
|
91 | % Document parameters | |
92 | ((* block title *))\title{((( resources.metadata.name | escape_latex )))}((* endblock title *)) |
|
92 | ((* block title *))\title{((( resources.metadata.name | escape_latex )))}((* endblock title *)) | |
93 | ((* block date *))((* endblock date *)) |
|
93 | ((* block date *))((* endblock date *)) | |
94 | ((* block author *))((* endblock author *)) |
|
94 | ((* block author *))((* endblock author *)) | |
95 | ((* endblock definitions *)) |
|
95 | ((* endblock definitions *)) | |
96 |
|
96 | |||
97 | ((* block commands *)) |
|
97 | ((* block commands *)) | |
98 | % Prevent overflowing lines due to hard-to-break entities |
|
98 | % Prevent overflowing lines due to hard-to-break entities | |
99 | \sloppy |
|
99 | \sloppy | |
100 | % Setup hyperref package |
|
100 | % Setup hyperref package | |
101 | \hypersetup{ |
|
101 | \hypersetup{ | |
102 | breaklinks=true, % so long urls are correctly broken across lines |
|
102 | breaklinks=true, % so long urls are correctly broken across lines | |
103 | colorlinks=true, |
|
103 | colorlinks=true, | |
104 | urlcolor=blue, |
|
104 | urlcolor=blue, | |
105 | linkcolor=darkorange, |
|
105 | linkcolor=darkorange, | |
106 | citecolor=darkgreen, |
|
106 | citecolor=darkgreen, | |
107 | } |
|
107 | } | |
108 | % Slightly bigger margins than the latex defaults |
|
108 | % Slightly bigger margins than the latex defaults | |
109 | ((* block margins *)) |
|
109 | ((* block margins *)) | |
110 | \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} |
|
110 | \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} | |
111 | ((* endblock margins *)) |
|
111 | ((* endblock margins *)) | |
112 | ((* endblock commands *)) |
|
112 | ((* endblock commands *)) | |
113 | ((* endblock header *)) |
|
113 | ((* endblock header *)) | |
114 |
|
114 | |||
115 | ((* block body *)) |
|
115 | ((* block body *)) | |
116 | \begin{document} |
|
116 | \begin{document} | |
117 |
|
117 | |||
118 | ((* block predoc *)) |
|
118 | ((* block predoc *)) | |
119 | ((* block maketitle *))\maketitle((* endblock maketitle *)) |
|
119 | ((* block maketitle *))\maketitle((* endblock maketitle *)) | |
120 | ((* block abstract *))((* endblock abstract *)) |
|
120 | ((* block abstract *))((* endblock abstract *)) | |
121 | ((* endblock predoc *)) |
|
121 | ((* endblock predoc *)) | |
122 |
|
122 | |||
123 | ((( super() ))) |
|
123 | ((( super() ))) | |
124 |
|
124 | |||
125 | % Add a bibliography block to the postdoc |
|
125 | % Add a bibliography block to the postdoc | |
126 | ((* block postdoc *)) |
|
126 | ((* block postdoc *)) | |
127 | ((* block bibliography *))((* endblock bibliography *)) |
|
127 | ((* block bibliography *))((* endblock bibliography *)) | |
128 | ((* endblock postdoc *)) |
|
128 | ((* endblock postdoc *)) | |
129 | \end{document} |
|
129 | \end{document} | |
130 | ((* endblock body *)) |
|
130 | ((* endblock body *)) | |
131 |
|
131 | |||
132 | %=============================================================================== |
|
132 | %=============================================================================== | |
133 | % Support blocks |
|
133 | % Support blocks | |
134 | %=============================================================================== |
|
134 | %=============================================================================== | |
135 |
|
135 | |||
136 | % Displaying simple data text |
|
136 | % Displaying simple data text | |
137 | ((* block data_text *)) |
|
137 | ((* block data_text *)) | |
138 | \begin{verbatim} |
|
138 | \begin{verbatim} | |
139 | ((( output.text ))) |
|
139 | ((( output.text ))) | |
140 | \end{verbatim} |
|
140 | \end{verbatim} | |
141 | ((* endblock data_text *)) |
|
141 | ((* endblock data_text *)) | |
142 |
|
142 | |||
143 | % Display python error text as-is |
|
143 | % Display python error text as-is | |
144 | ((* block pyerr *)) |
|
144 | ((* block pyerr *)) | |
145 | \begin{Verbatim}[commandchars=\\\{\}] |
|
145 | \begin{Verbatim}[commandchars=\\\{\}] | |
146 | ((( super() ))) |
|
146 | ((( super() ))) | |
147 | \end{Verbatim} |
|
147 | \end{Verbatim} | |
148 | ((* endblock pyerr *)) |
|
148 | ((* endblock pyerr *)) | |
149 | ((* block traceback_line *)) |
|
149 | ((* block traceback_line *)) | |
150 | ((( line | indent | strip_ansi | escape_latex ))) |
|
150 | ((( line | indent | strip_ansi | escape_latex ))) | |
151 | ((* endblock traceback_line *)) |
|
151 | ((* endblock traceback_line *)) | |
152 |
|
152 | |||
153 | % Display stream ouput with coloring |
|
153 | % Display stream ouput with coloring | |
154 | ((* block stream *)) |
|
154 | ((* block stream *)) | |
155 | \begin{Verbatim}[commandchars=\\\{\}] |
|
155 | \begin{Verbatim}[commandchars=\\\{\}] | |
156 | ((( output.text | escape_latex | ansi2latex ))) |
|
156 | ((( output.text | escape_latex | ansi2latex ))) | |
157 | \end{Verbatim} |
|
157 | \end{Verbatim} | |
158 | ((* endblock stream *)) |
|
158 | ((* endblock stream *)) | |
159 |
|
159 | |||
160 | % Display latex |
|
160 | % Display latex | |
161 | ((* block data_latex -*)) |
|
161 | ((* block data_latex -*)) | |
162 | ((*- if output.latex.startswith('$'): -*)) |
|
162 | ((*- if output.latex.startswith('$'): -*)) | |
163 | ((= Replace $ symbols with more explicit, equation block. =)) |
|
163 | ((= Replace $ symbols with more explicit, equation block. =)) | |
164 | \begin{equation*} |
|
164 | \begin{equation*} | |
165 | ((( output.latex | strip_dollars ))) |
|
165 | ((( output.latex | strip_dollars ))) | |
166 | \end{equation*} |
|
166 | \end{equation*} | |
167 | ((*- else -*)) |
|
167 | ((*- else -*)) | |
168 | ((( output.latex ))) |
|
168 | ((( output.latex ))) | |
169 | ((*- endif *)) |
|
169 | ((*- endif *)) | |
170 | ((* endblock data_latex *)) |
|
170 | ((* endblock data_latex *)) | |
171 |
|
171 | |||
172 | % Default mechanism for rendering figures |
|
172 | % Default mechanism for rendering figures | |
173 | ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*)) |
|
173 | ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*)) | |
174 | ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*)) |
|
174 | ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*)) | |
175 | ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*)) |
|
175 | ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*)) | |
176 | ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*)) |
|
176 | ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*)) | |
177 |
|
177 | |||
178 | % Draw a figure using the graphicx package. |
|
178 | % Draw a figure using the graphicx package. | |
179 | ((* macro draw_figure(filename) -*)) |
|
179 | ((* macro draw_figure(filename) -*)) | |
180 | ((* set filename = filename | posix_path *)) |
|
180 | ((* set filename = filename | posix_path *)) | |
181 | ((*- block figure scoped -*)) |
|
181 | ((*- block figure scoped -*)) | |
182 | \begin{center} |
|
182 | \begin{center} | |
183 | \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))} |
|
183 | \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))} | |
184 | \end{center} |
|
184 | \end{center} | |
185 | { \hspace*{\fill} \\} |
|
185 | { \hspace*{\fill} \\} | |
186 | ((*- endblock figure -*)) |
|
186 | ((*- endblock figure -*)) | |
187 | ((*- endmacro *)) |
|
187 | ((*- endmacro *)) | |
188 |
|
188 | |||
189 | % Draw heading cell. Explicitly map different cell levels. |
|
189 | % Draw heading cell. Explicitly map different cell levels. | |
190 | ((* block headingcell scoped *)) |
|
190 | ((* block headingcell scoped *)) | |
191 |
|
191 | |||
192 | ((* if cell.level == 1 -*)) |
|
192 | ((* if cell.level == 1 -*)) | |
193 | ((* block h1 -*))\section((* endblock h1 -*)) |
|
193 | ((* block h1 -*))\section((* endblock h1 -*)) | |
194 | ((* elif cell.level == 2 -*)) |
|
194 | ((* elif cell.level == 2 -*)) | |
195 | ((* block h2 -*))\subsection((* endblock h2 -*)) |
|
195 | ((* block h2 -*))\subsection((* endblock h2 -*)) | |
196 | ((* elif cell.level == 3 -*)) |
|
196 | ((* elif cell.level == 3 -*)) | |
197 | ((* block h3 -*))\subsubsection((* endblock h3 -*)) |
|
197 | ((* block h3 -*))\subsubsection((* endblock h3 -*)) | |
198 | ((* elif cell.level == 4 -*)) |
|
198 | ((* elif cell.level == 4 -*)) | |
199 | ((* block h4 -*))\paragraph((* endblock h4 -*)) |
|
199 | ((* block h4 -*))\paragraph((* endblock h4 -*)) | |
200 | ((* elif cell.level == 5 -*)) |
|
200 | ((* elif cell.level == 5 -*)) | |
201 | ((* block h5 -*))\subparagraph((* endblock h5 -*)) |
|
201 | ((* block h5 -*))\subparagraph((* endblock h5 -*)) | |
202 | ((* elif cell.level == 6 -*)) |
|
202 | ((* elif cell.level == 6 -*)) | |
203 | ((* block h6 -*))\\*\textit((* endblock h6 -*)) |
|
203 | ((* block h6 -*))\\*\textit((* endblock h6 -*)) | |
204 | ((*- endif -*)) |
|
204 | ((*- endif -*)) | |
205 | {((( cell.source | replace('\n', ' ') | citation2latex | markdown2latex )))} |
|
205 | {((( cell.source | replace('\n', ' ') | citation2latex | strip_url_static_file_prefix | markdown2latex )))} | |
206 |
|
206 | |||
207 | ((* endblock headingcell *)) |
|
207 | ((* endblock headingcell *)) | |
208 |
|
208 | |||
209 | % Redirect pyout to display data priority. |
|
209 | % Redirect pyout to display data priority. | |
210 | ((* block pyout scoped *)) |
|
210 | ((* block pyout scoped *)) | |
211 | ((* block data_priority scoped *)) |
|
211 | ((* block data_priority scoped *)) | |
212 | ((( super() ))) |
|
212 | ((( super() ))) | |
213 | ((* endblock *)) |
|
213 | ((* endblock *)) | |
214 | ((* endblock pyout *)) |
|
214 | ((* endblock pyout *)) | |
215 |
|
215 | |||
216 | % Render markdown |
|
216 | % Render markdown | |
217 | ((* block markdowncell scoped *)) |
|
217 | ((* block markdowncell scoped *)) | |
218 | ((( cell.source | citation2latex | markdown2latex ))) |
|
218 | ((( cell.source | citation2latex | strip_url_static_file_prefix | markdown2latex ))) | |
219 | ((* endblock markdowncell *)) |
|
219 | ((* endblock markdowncell *)) | |
220 |
|
220 | |||
221 | % Spit out the contents of raw cells unmodified |
|
221 | % Spit out the contents of raw cells unmodified | |
222 | ((* block rawcell scoped *)) |
|
222 | ((* block rawcell scoped *)) | |
223 | ((( cell.source ))) |
|
223 | ((( cell.source ))) | |
224 | ((* endblock rawcell *)) |
|
224 | ((* endblock rawcell *)) | |
225 |
|
225 | |||
226 | % Don't display unknown types |
|
226 | % Don't display unknown types | |
227 | ((* block unknowncell scoped *)) |
|
227 | ((* block unknowncell scoped *)) | |
228 | ((* endblock unknowncell *)) |
|
228 | ((* endblock unknowncell *)) |
General Comments 0
You need to be logged in to leave comments.
Login now