Reference¶
- class nbpreview.notebook.Notebook(notebook_node, theme='ansi_dark', plain=None, unicode=None, hide_output=False, nerd_font=False, files=True, negative_space=True, hyperlinks=None, hide_hyperlink_hints=False, images=None, image_drawing=None, color=None, relative_dir=None, line_numbers=False, code_wrap=False)¶
Construct a Notebook object to render Jupyter Notebooks.
- Parameters:
notebook_node (
NotebookNode) – A NotebookNode of the notebook to render.theme (
str) – The theme to use for syntax highlighting. May be'ansi_light','ansi_dark', or any Pygments theme. By default'ansi_dark'.plain (
bool|None) – Only show plain style. No decorations such as boxes or execution counts. If set toNonewill autodetect. By defaultNone.unicode (
bool|None) – Whether to use unicode characters to render the notebook. If set toNonewill autodetect. By defaultNone.hide_output (
bool) – Do not render the notebook outputs. By defaultFalse.nerd_font (
bool) – Use nerd fonts when appropriate. By defaultFalse.files (
bool) – Create files when needed to render HTML content. By defaultTrue.negative_space (
bool) – Whether render character images in negative space. By defaultTruehyperlinks (
bool|None) – Whether to use hyperlinks. IfFalsewill explicitly print out path. If set toNonewill autodetect. By defaultNone.hide_hyperlink_hints (
bool) – Hide text hints of when content is clickable. By defaultFalse.images (
bool|None) – Whether to render images. If set toNonewill autodetect. By defaultNone.image_drawing (
Union[ImageDrawingEnum,Literal['block','character','braille'],None]) – The characters used to render images. Options are'block','character','braille'orNone. If set toNonewill autodetect. By defaultNone.color (
bool|None) – Whether to use color. If set toNonewill autodetect. By defaultNone.relative_dir (
InitVar) – The directory to prefix relative paths to convert them to absolute. IfNonewill assume current directory is relative prefix. By defaultNone.line_numbers (
bool) – Whether to render line numbers in code cells. By defaultFalse.code_wrap (
bool) – Whether to wrap code if it does not fit. By defaultFalse.
- classmethod from_file(file, theme='ansi_dark', plain=None, unicode=None, hide_output=False, nerd_font=False, files=True, negative_space=True, hyperlinks=None, hide_hyperlink_hints=False, images=None, image_drawing=None, color=None, line_numbers=False, code_wrap=False)¶
Create a Notebook from notebook file.
- Parameters:
file (
Union[Path,IO[AnyStr],KeepOpenFile]) – A path to a Jupyter Notebook file.theme (
str) – The theme to use for syntax highlighting. May be'ansi_light','ansi_dark', or any Pygments theme. By default'ansi_dark'.plain (
bool|None) – Only show plain style. No decorations such as boxes or execution counts. If set toNonewill autodetect. By defaultNone.unicode (
bool|None) – Whether to use unicode characters to render the notebook. If set toNonewill autodetect. By defaultNone.hide_output (
bool) – Do not render the notebook outputs. By defaultFalse.nerd_font (
bool) – Use nerd fonts when appropriate. By defaultFalse.files (
bool) – Create files when needed to render HTML content. By defaultTrue.negative_space (
bool) – Whether render character images in negative space. By defaultTrue.hyperlinks (
bool|None) – Whether to use hyperlinks. IfFalsewill explicitly print out path. If set toNonewill autodetect. By defaultNone.hide_hyperlink_hints (
bool) – Hide text hints of when content is clickable. By defaultFalse.images (
bool|None) – Whether to render images. If set toNonewill autodetect. By defaultNone.image_drawing (
Union[ImageDrawingEnum,Literal['block','character','braille'],None]) – The characters used to render images. Options are'block','character','braille'orNone. If set toNonewill autodetect. By defaultNone.color (
bool|None) – Whether to use color. If set toNonewill autodetect. By defaultNone.line_numbers (
bool) – Whether to render line numbers in code cells. By defaultFalse.code_wrap (
bool) – Whether to wrap code if it does not fit. By defaultFalse.
- Returns:
A Notebook object created from the file.
- Return type:
- Raises:
InvalidNotebookError – If the file is not a valid Jupyter notebook.