Utility Reference#

class common_nb_preprocessors.myst_nb.MystNBCellTags#

All different Myst-NB cell tag configuration options.

hide_input = 'hide-input'#

Hide the source code of the cell behind a collapsible button. See hide-input for a visual example.

hide_output = 'hide-output'#

Hide the output of the cell behind a collapsible button. See hide-output for a visual example.

hide_cell = 'hide-cell'#

Hide the input as well as the output of the cell behind a collapsible button. See hide-cell for a visual example.

remove_input = 'remove-input'#

Removes the source code of the cell. See remove-input for a visual example.

remove_stderr = 'remove-stderr'#

Only remove the standard error output of the code cell. See remove-stderr for a visual example.

remove_output = 'remove-output'#

Remove the output of the code cell. See remove-output for a visual example.

remove_cell = 'remove-cell'#

Remove the input as well as the output of the code cell. See remove-cell for a visual example.

raises_exception = 'raises-exception'#

Continue execution normally if code cell raises exception. See raises-exception for a visual example.

skip_execution = 'skip-execution'#

Do not execute code cell. See skip-execution for a visual example.

class common_nb_preprocessors.myst_nb.MystNBCellConf#

All different Myst-NB cell metadata configuration options. These keys must be paired with a value.

remove_code_source = 'remove_code_source'#

Remove the code cell. Should be paired with a boolean: true/false. See remove_code_source for a visual example.

remove_code_outputs = 'remove_code_outputs'#

Remove the output of the cell. Should be paired with a boolean: true/false. See remove_code_outputs for a visual example.

number_source_lines = 'number_source_lines'#

Add source line numbering to the current cell. Should be paired with a boolean: true/false. See number_source_lines for a visual example.

output_stderr = 'output_stderr'#

Define the behavior for standard error output. Should be paired with one of the following strings:

  • show: Show the standard error as a separate output

  • remove: Remove the standard error output

  • remove-warn: Remove the standard error output but log a warning to Sphinx

  • warn/error/severe: Log the error with a specific logging level to Sphinx

See output_stderr for a visual example.

code_prompt_show = 'code_prompt_show'#

Define the prompt text that is displayed next to the expand/show dialog. The text is displayed to inform the user that the dialog can be expanded.

The optional {type} placeholder will be replaced with: content, source, or outputs, depending on the hide tag.

See code_prompt_show for a visual example.

code_prompt_hide = 'code_prompt_hide'#

Define the prompt text that is displayed next to the hide dialog. The text is displayed to inform the user that the dialog can be collapsed/minimized.

The optional {type} placeholder will be replaced with: content, source, or outputs, depending on the hide tag.

See code_prompt_hide for a visual example.

merge_streams = 'merge_streams'#

Merge standard output and standard error into a single output cell. Should be paired with a boolean: true/false.

See merge_streams for a visual example.

text_lexer = 'text_lexer'#

Pygments lexer applied to standard out, standard error and text/plain outputs. Should be paired with a Pygments lexer string.

See text_lexer for a visual example.

error_lexer = 'error_lexer'#

Pygments lexer applied to the error/traceback outputs. Should be paired with a Pygments lexer string.

See error_lexer for a visual example.

markdown_format = 'markdown_format'#

The format to use for text/markdown rendering. Should be paired with one of the following strings:

  • commonmark (Default)

  • gfm

  • myst

See markdown_format for a visual example.

image = 'image'#

Options for image outputs.

See image for a visual example.

figure = 'figure'#

Options for figure outputs. To see a list of all possible configuration values, take a look at the official figure documentation.

See figure for a visual example.

common_nb_preprocessors.myst_nb.myst_nb_metadata_injector(file_content, /, prefix='#', remove_line=True, delimiter='=', extra_tags=None)#

The preprocessor will inject all the MyST-NB specific tags into the metadata tags and the cell level configuration to the mystnb field. For an in-depth explanation of the different values, see the cell-config and the tag section of the MyST-NB documentation.

Parameters
  • file_content (str) – contents of an ipynb file

  • prefix (str) – Comment symbol that precedes the keys. Defaults to #.

  • remove_line (bool) – Set if the metadata comment lines should be removed after injection. Defaults to True.

  • extra_tags (Optional[List[str]]) – Additional custom tags list for further customization.

  • delimiter (str) –

Return type

nbformat.notebooknode.NotebookNode

Internally it calls MetaDataListInjectorPrepreprocessor and MetaDataMapInjectorPreprocessor. Refer to those classes for more details.