ipypublish.preprocessors.latex_doc_defaults module

class ipypublish.preprocessors.latex_doc_defaults.MetaDefaults(**kw)[source]

Bases: nbconvert.preprocessors.base.Preprocessor

a preprocessor which enters default metadata tags into all cell metadata, without overriding any currently set


An instance of a Python dict.


An instance of a Python dict.


A boolean (True, False) trait.

preprocess(nb, resources)[source]

Preprocessing to apply on each notebook.

Must return modified nb, resources.

If you wish to apply your preprocessing to each cell, you might want to override preprocess_cell method instead.

  • nb (NotebookNode) – Notebook being converted
  • resources (dictionary) – Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.
ipypublish.preprocessors.latex_doc_defaults.flatten(d, key_as_tuple=True, sep='.')[source]

get nested dict as {key:val,…}, where key is tuple/string of all nested keys

  • d (dict) –
  • key_as_tuple (bool) – whether keys are list of nested keys or delimited string of nested keys
  • sep (str) – if key_as_tuple=False, delimiter for keys


>>> from pprint import pprint
>>> d = {1:{"a":"A"},2:{"b":"B"}}
>>> pprint(flatten(d))
{(1, 'a'): 'A', (2, 'b'): 'B'}
>>> d = {1:{"a":"A"},2:{"b":"B"}}
>>> pprint(flatten(d,key_as_tuple=False))
{'1.a': 'A', '2.b': 'B'}