Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AllenDowney
GitHub Repository: AllenDowney/bayesian-analysis-recipes
Path: blob/master/nbconvert_config.py
409 views
1
from pathlib import Path
2
import os
3
4
# Configuration file for jupyter-nbconvert.
5
6
#------------------------------------------------------------------------------
7
# Application(SingletonConfigurable) configuration
8
#------------------------------------------------------------------------------
9
10
## This is an application.
11
12
## The date format used by logging formatters for %(asctime)s
13
#c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
14
15
## The Logging format template
16
#c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
17
18
## Set the log level by value or name.
19
#c.Application.log_level = 30
20
21
#------------------------------------------------------------------------------
22
# JupyterApp(Application) configuration
23
#------------------------------------------------------------------------------
24
25
## Base class for Jupyter applications
26
27
## Answer yes to any prompts.
28
#c.JupyterApp.answer_yes = False
29
30
## Full path of a config file.
31
#c.JupyterApp.config_file = ''
32
33
## Specify a config file to load.
34
#c.JupyterApp.config_file_name = ''
35
36
## Generate default config file.
37
#c.JupyterApp.generate_config = False
38
39
#------------------------------------------------------------------------------
40
# NbConvertApp(JupyterApp) configuration
41
#------------------------------------------------------------------------------
42
43
## This application is used to convert notebook files (*.ipynb) to various other
44
# formats.
45
#
46
# WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES.
47
48
## The export format to be used, either one of the built-in formats, or a dotted
49
# object name that represents the import path for an `Exporter` class
50
#c.NbConvertApp.export_format = 'html'
51
52
## read a single notebook from stdin.
53
#c.NbConvertApp.from_stdin = False
54
55
## List of notebooks to convert. Wildcards are supported. Filenames passed
56
# positionally will be added to the list.
57
c.NbConvertApp.notebooks = ['notebooks/*.ipynb']
58
59
## overwrite base name use for output files. can only be used when converting one
60
# notebook at a time.
61
# c.NbConvertApp.output_base = ''
62
63
## Directory to copy extra files (figures) to. '{notebook_name}' in the string
64
# will be converted to notebook basename
65
#c.NbConvertApp.output_files_dir = '{notebook_name}_files'
66
67
## PostProcessor class used to write the results of the conversion
68
#c.NbConvertApp.postprocessor_class = ''
69
70
## Whether to apply a suffix prior to the extension (only relevant when
71
# converting to notebook format). The suffix is determined by the exporter, and
72
# is usually '.nbconvert'.
73
#c.NbConvertApp.use_output_suffix = True
74
75
## Writer class used to write the results of the conversion
76
#c.NbConvertApp.writer_class = 'FilesWriter'
77
78
#------------------------------------------------------------------------------
79
# NbConvertBase(LoggingConfigurable) configuration
80
#------------------------------------------------------------------------------
81
82
## Global configurable class for shared config
83
#
84
# Useful for display data priority that might be used by many transformers
85
86
## Deprecated default highlight language as of 5.0, please use language_info
87
# metadata instead
88
#c.NbConvertBase.default_language = 'ipython'
89
90
## An ordered list of preferred output type, the first encountered will usually
91
# be used when converting discarding the others.
92
#c.NbConvertBase.display_data_priority = ['text/html', 'application/pdf', 'text/latex', 'image/svg+xml', 'image/png', 'image/jpeg',
93
# 'text/markdown', 'text/plain']
94
95
#------------------------------------------------------------------------------
96
# Exporter(LoggingConfigurable) configuration
97
#------------------------------------------------------------------------------
98
99
# Class containing methods that sequentially run a list of preprocessors on a
100
# NotebookNode object and then return the modified NotebookNode object and
101
# accompanying resources dict.
102
103
104
# List of preprocessors available by default, by name, namespace, instance,
105
# or type.
106
c.Exporter.default_preprocessors = ['nbconvert.preprocessors.ExecutePreprocessor',
107
'nbconvert.preprocessors.coalesce_streams',
108
'nbconvert.preprocessors.SVG2PDFPreprocessor',
109
'nbconvert.preprocessors.CSSHTMLHeaderPreprocessor',
110
'nbconvert.preprocessors.LatexPreprocessor',
111
'nbconvert.preprocessors.HighlightMagicsPreprocessor',
112
'nbconvert.preprocessors.ExtractOutputPreprocessor']
113
114
## Extension of the file that should be written to disk
115
#c.Exporter.file_extension = '.txt'
116
117
## List of preprocessors, by name or namespace, to enable.
118
#c.Exporter.preprocessors = []
119
120
#------------------------------------------------------------------------------
121
# TemplateExporter(Exporter) configuration
122
#------------------------------------------------------------------------------
123
124
## Exports notebooks into other file formats. Uses Jinja 2 templating engine to
125
# output new formats. Inherit from this class if you are creating a new
126
# template type along with new filters/preprocessors. If the filters/
127
# preprocessors provided by default suffice, there is no need to inherit from
128
# this class. Instead, override the template_file and file_extension traits via
129
# a config file.
130
#
131
# Filters available by default for templates:
132
#
133
# - add_anchor - add_prompts - ansi2html - ansi2latex - ascii_only -
134
# citation2latex - comment_lines - convert_pandoc - escape_latex -
135
# filter_data_type - get_lines - get_metadata - highlight2html - highlight2latex
136
# - html2text - indent - ipython2python - json_dumps - markdown2asciidoc -
137
# markdown2html - markdown2latex - markdown2rst - path2url - posix_path -
138
# prevent_list_blocks - strip_ansi - strip_dollars - strip_files_prefix -
139
# wrap_text
140
141
## Dictionary of filters, by name and namespace, to add to the Jinja environment.
142
#c.TemplateExporter.filters = {}
143
144
## formats of raw cells to be included in this Exporter's output.
145
#c.TemplateExporter.raw_mimetypes = []
146
147
##
148
#c.TemplateExporter.template_extension = '.tpl'
149
150
## Name of the template file to use
151
#c.TemplateExporter.template_file = ''
152
153
##
154
#c.TemplateExporter.template_path = ['.']
155
156
#------------------------------------------------------------------------------
157
# ASCIIDocExporter(TemplateExporter) configuration
158
#------------------------------------------------------------------------------
159
160
## Exports to an ASCIIDoc document (.asciidoc)
161
162
#------------------------------------------------------------------------------
163
# HTMLExporter(TemplateExporter) configuration
164
#------------------------------------------------------------------------------
165
166
## Exports a basic HTML document. This exporter assists with the export of HTML.
167
# Inherit from it if you are writing your own HTML template and need custom
168
# preprocessors/filters. If you don't need custom preprocessors/ filters, just
169
# change the 'template_file' config option.
170
171
#------------------------------------------------------------------------------
172
# LatexExporter(TemplateExporter) configuration
173
#------------------------------------------------------------------------------
174
175
## Exports to a Latex template. Inherit from this class if your template is
176
# LaTeX based and you need custom tranformers/filters. Inherit from it if you
177
# are writing your own HTML template and need custom tranformers/filters. If
178
# you don't need custom tranformers/filters, just change the 'template_file'
179
# config option. Place your template in the special "/latex" subfolder of the
180
# "../templates" folder.
181
182
##
183
#c.LatexExporter.template_extension = '.tplx'
184
185
#------------------------------------------------------------------------------
186
# MarkdownExporter(TemplateExporter) configuration
187
#------------------------------------------------------------------------------
188
189
## Exports to a markdown document (.md)
190
191
#------------------------------------------------------------------------------
192
# NotebookExporter(Exporter) configuration
193
#------------------------------------------------------------------------------
194
195
## Exports to an IPython notebook.
196
#
197
# This is useful when you want to use nbconvert's preprocessors to operate on a
198
# notebook (e.g. to execute it) and then write it back to a notebook file.
199
200
## The nbformat version to write. Use this to downgrade notebooks.
201
#c.NotebookExporter.nbformat_version = 4
202
203
#------------------------------------------------------------------------------
204
# PDFExporter(LatexExporter) configuration
205
#------------------------------------------------------------------------------
206
207
## Writer designed to write to PDF files.
208
#
209
# This inherits from :class:`LatexExporter`. It creates a LaTeX file in a
210
# temporary directory using the template machinery, and then runs LaTeX to
211
# create a pdf.
212
213
## Shell command used to run bibtex.
214
#c.PDFExporter.bib_command = ['bibtex', '{filename}']
215
216
## Shell command used to compile latex.
217
#c.PDFExporter.latex_command = ['xelatex', '{filename}']
218
219
## How many times latex will be called.
220
#c.PDFExporter.latex_count = 3
221
222
## File extensions of temp files to remove after running.
223
#c.PDFExporter.temp_file_exts = ['.aux', '.bbl', '.blg', '.idx', '.log', '.out']
224
225
## Whether to display the output of latex commands.
226
#c.PDFExporter.verbose = False
227
228
#------------------------------------------------------------------------------
229
# PythonExporter(TemplateExporter) configuration
230
#------------------------------------------------------------------------------
231
232
## Exports a Python code file.
233
234
#------------------------------------------------------------------------------
235
# RSTExporter(TemplateExporter) configuration
236
#------------------------------------------------------------------------------
237
238
## Exports reStructuredText documents.
239
240
#------------------------------------------------------------------------------
241
# ScriptExporter(TemplateExporter) configuration
242
#------------------------------------------------------------------------------
243
244
#------------------------------------------------------------------------------
245
# SlidesExporter(HTMLExporter) configuration
246
#------------------------------------------------------------------------------
247
248
## Exports HTML slides with reveal.js
249
250
## The URL prefix for reveal.js. This can be a a relative URL for a local copy of
251
# reveal.js, or point to a CDN.
252
#
253
# For speaker notes to work, a local reveal.js prefix must be used.
254
#c.SlidesExporter.reveal_url_prefix = ''
255
256
#------------------------------------------------------------------------------
257
# Preprocessor(NbConvertBase) configuration
258
#------------------------------------------------------------------------------
259
260
## A configurable preprocessor
261
#
262
# Inherit from this class if you wish to have configurability for your
263
# preprocessor.
264
#
265
# Any configurable traitlets this class exposed will be configurable in profiles
266
# using c.SubClassName.attribute = value
267
#
268
# you can overwrite :meth:`preprocess_cell` to apply a transformation
269
# independently on each cell or :meth:`preprocess` if you prefer your own logic.
270
# See corresponding docstring for informations.
271
#
272
# Disabled by default and can be enabled via the config by
273
# 'c.YourPreprocessorName.enabled = True'
274
275
##
276
#c.Preprocessor.enabled = False
277
278
#------------------------------------------------------------------------------
279
# CSSHTMLHeaderPreprocessor(Preprocessor) configuration
280
#------------------------------------------------------------------------------
281
282
## Preprocessor used to pre-process notebook for HTML output. Adds IPython
283
# notebook front-end CSS and Pygments CSS to HTML output.
284
285
## CSS highlight class identifier
286
#c.CSSHTMLHeaderPreprocessor.highlight_class = '.highlight'
287
288
#------------------------------------------------------------------------------
289
# ClearOutputPreprocessor(Preprocessor) configuration
290
#------------------------------------------------------------------------------
291
292
## Removes the output from all code cells in a notebook.
293
294
#------------------------------------------------------------------------------
295
# ConvertFiguresPreprocessor(Preprocessor) configuration
296
#------------------------------------------------------------------------------
297
298
## Converts all of the outputs in a notebook from one format to another.
299
300
## Format the converter accepts
301
#c.ConvertFiguresPreprocessor.from_format = ''
302
303
## Format the converter writes
304
#c.ConvertFiguresPreprocessor.to_format = ''
305
306
#------------------------------------------------------------------------------
307
# ExecutePreprocessor(Preprocessor) configuration
308
#------------------------------------------------------------------------------
309
310
## Executes all the cells in a notebook
311
312
## If `False` (default), when a cell raises an error the execution is stopped and
313
# a `CellExecutionError` is raised. If `True`, execution errors are ignored and
314
# the execution is continued until the end of the notebook. Output from
315
# exceptions is included in the cell output in both cases.
316
#c.ExecutePreprocessor.allow_errors = False
317
318
## If execution of a cell times out, interrupt the kernel and continue executing
319
# other cells rather than throwing an error and stopping.
320
#c.ExecutePreprocessor.interrupt_on_timeout = False
321
322
## The time to wait (in seconds) for IOPub output. This generally doesn't need to
323
# be set, but on some slow networks (such as CI systems) the default timeout
324
# might not be long enough to get all messages.
325
#c.ExecutePreprocessor.iopub_timeout = 4
326
327
## The kernel manager class to use.
328
#c.ExecutePreprocessor.kernel_manager_class = 'jupyter_client.manager.KernelManager'
329
330
## Name of kernel to use to execute the cells. If not set, use the kernel_spec
331
# embedded in the notebook.
332
c.ExecutePreprocessor.kernel_name = 'bayesian'
333
334
## If `False` (default), then the kernel will continue waiting for iopub messages
335
# until it receives a kernel idle message, or until a timeout occurs, at which
336
# point the currently executing cell will be skipped. If `True`, then an error
337
# will be raised after the first timeout. This option generally does not need to
338
# be used, but may be useful in contexts where there is the possibility of
339
# executing notebooks with memory-consuming infinite loops.
340
#c.ExecutePreprocessor.raise_on_iopub_timeout = False
341
342
## If `graceful` (default), then the kernel is given time to clean up after
343
# executing all cells, e.g., to execute its `atexit` hooks. If `immediate`, then
344
# the kernel is signaled to immediately terminate.
345
#c.ExecutePreprocessor.shutdown_kernel = 'graceful'
346
347
## The time to wait (in seconds) for output from executions. If a cell execution
348
# takes longer, an exception (TimeoutError on python 3+, RuntimeError on python
349
# 2) is raised.
350
#
351
# `None` or `-1` will disable the timeout. If `timeout_func` is set, it
352
# overrides `timeout`.
353
c.ExecutePreprocessor.timeout = 600
354
355
## A callable which, when given the cell source as input, returns the time to
356
# wait (in seconds) for output from cell executions. If a cell execution takes
357
# longer, an exception (TimeoutError on python 3+, RuntimeError on python 2) is
358
# raised.
359
#
360
# Returning `None` or `-1` will disable the timeout for the cell. Not setting
361
# `timeout_func` will cause the preprocessor to default to using the `timeout`
362
# trait for all cells. The `timeout_func` trait overrides `timeout` if it is not
363
# `None`.
364
#c.ExecutePreprocessor.timeout_func = None
365
366
#------------------------------------------------------------------------------
367
# ExtractOutputPreprocessor(Preprocessor) configuration
368
#------------------------------------------------------------------------------
369
370
## Extracts all of the outputs from the notebook file. The extracted outputs
371
# are returned in the 'resources' dictionary.
372
373
##
374
#c.ExtractOutputPreprocessor.extract_output_types = {'image/jpeg', 'image/png', 'application/pdf', 'image/svg+xml'}
375
376
##
377
#c.ExtractOutputPreprocessor.output_filename_template = '{unique_key}_{cell_index}_{index}{extension}'
378
379
#------------------------------------------------------------------------------
380
# HighlightMagicsPreprocessor(Preprocessor) configuration
381
#------------------------------------------------------------------------------
382
383
## Detects and tags code cells that use a different languages than Python.
384
385
## Syntax highlighting for magic's extension languages. Each item associates a
386
# language magic extension such as %%R, with a pygments lexer such as r.
387
#c.HighlightMagicsPreprocessor.languages = {}
388
389
#------------------------------------------------------------------------------
390
# LatexPreprocessor(Preprocessor) configuration
391
#------------------------------------------------------------------------------
392
393
## Preprocessor for latex destined documents.
394
#
395
# Mainly populates the `latex` key in the resources dict, adding definitions for
396
# pygments highlight styles.
397
398
#------------------------------------------------------------------------------
399
# SVG2PDFPreprocessor(ConvertFiguresPreprocessor) configuration
400
#------------------------------------------------------------------------------
401
402
## Converts all of the outputs in a notebook from SVG to PDF.
403
404
## The command to use for converting SVG to PDF
405
#
406
# This string is a template, which will be formatted with the keys to_filename
407
# and from_filename.
408
#
409
# The conversion call must read the SVG from {from_flename}, and write a PDF to
410
# {to_filename}.
411
#c.SVG2PDFPreprocessor.command = ''
412
413
## The path to Inkscape, if necessary
414
#c.SVG2PDFPreprocessor.inkscape = ''
415
416
#------------------------------------------------------------------------------
417
# WriterBase(NbConvertBase) configuration
418
#------------------------------------------------------------------------------
419
420
## Consumes output from nbconvert export...() methods and writes to a useful
421
# location.
422
423
## List of the files that the notebook references. Files will be included with
424
# written output.
425
#c.WriterBase.files = []
426
427
#------------------------------------------------------------------------------
428
# DebugWriter(WriterBase) configuration
429
#------------------------------------------------------------------------------
430
431
## Consumes output from nbconvert export...() methods and writes usefull
432
# debugging information to the stdout. The information includes a list of
433
# resources that were extracted from the notebook(s) during export.
434
435
#------------------------------------------------------------------------------
436
# FilesWriter(WriterBase) configuration
437
#------------------------------------------------------------------------------
438
439
## Consumes nbconvert output and produces files.
440
441
## Directory to write output(s) to. Defaults to output to the directory of each
442
# notebook. To recover previous default behaviour (outputting to the current
443
# working directory) use . as the flag value.
444
c.FilesWriter.build_directory = 'docs'
445
446
## When copying files that the notebook depends on, copy them in relation to this
447
# path, such that the destination filename will be os.path.relpath(filename,
448
# relpath). If FilesWriter is operating on a notebook that already exists
449
# elsewhere on disk, then the default will be the directory containing that
450
# notebook.
451
#c.FilesWriter.relpath = ''
452
453
#------------------------------------------------------------------------------
454
# StdoutWriter(WriterBase) configuration
455
#------------------------------------------------------------------------------
456
457
## Consumes output from nbconvert export...() methods and writes to the stdout
458
# stream.
459
460
#------------------------------------------------------------------------------
461
# PostProcessorBase(NbConvertBase) configuration
462
#------------------------------------------------------------------------------
463
464
#------------------------------------------------------------------------------
465
# ServePostProcessor(PostProcessorBase) configuration
466
#------------------------------------------------------------------------------
467
468
## Post processor designed to serve files
469
#
470
# Proxies reveal.js requests to a CDN if no local reveal.js is present
471
472
## The IP address to listen on.
473
#c.ServePostProcessor.ip = '127.0.0.1'
474
475
## Should the browser be opened automatically?
476
#c.ServePostProcessor.open_in_browser = True
477
478
## port for the server to listen on.
479
#c.ServePostProcessor.port = 8000
480
481
## URL for reveal.js CDN.
482
#c.ServePostProcessor.reveal_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.1.0'
483
484
## URL prefix for reveal.js
485
#c.ServePostProcessor.reveal_prefix = 'reveal.js'
486
487