1.1.13 • Published 3 years ago

react-jupyter-notebook-viewer v1.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Jupyter Notebook Viewer

Version Bundle Size Total Downloads License Type Used by React Markdown React Syntax Highlighter Buy Coffee


Render Jupyter notebook files easily in your React/NextJS project to showcase your notebooks.

React Jupyter Notebook Viewer is a highly customizable static viewer for React. Therefore this package will never ever be transformed into an interactive Jupyter Notebook viewer.

Try it yourself!

Demo GIF

Install

npm install react-jupyter-notebook-viewer

Usage

React Applications

// App.js
import { JupyterNotebookViewer } from "react-jupyter-notebook-viewer";

export default function App() {
	return (
		<JupyterNotebookViewer
			filePath="/path/to/notebook" // Or a raw JSON notebook file location online
			notebookInputLanguage="python"
			// Rest of the properties if required.
		/>
	);
}

NextJS Applications

⚠️ DISCLAIMER

Using this package in a NextJS application requires a different approach.

  1. Create a component using the package inside the /components/Notebook.js file:
// components/Notebook.js
import { JupyterNotebookViewer } from "react-jupyter-notebook-viewer";

function Notebook(props) {
	const notebook = new JupyterNotebookViewer(props);
	return <>{notebook}</>;
}

export default Notebook;
  1. Use the created component in the desired file:
// pages/index.js
import dynamic from "next/dynamic";

const Notebook = dynamic(() => import("../components/Notebook"), {
	ssr: false
});

export default function IndexPage() {
	return (
		<Notebook
			filePath="/path/to/notebook" // Or a raw JSON notebook file location online
			notebookInputLanguage="python"
			// Rest of the properties if required.
		/>
	);
}

Types

PropertyDescriptionRequiredTypeDefault Value
filePathThe path to the Jupyter notebook file (.ipynb)✔️string-
classNameThe class name of the static viewerstring-
notebookInputLanguageThe Jupyter notebook input code languagestring-
notebookOutputLanguageThe Jupyter notebook output code languagestringnotebookOutputLanguage \|\| notebookInputLanguage
outputTextClassNameThe Jupyter notebook output block execution number class namestring-
inputTextClassNameThe Jupyter notebook input block execution number class namestring-
outputBlockClassNameThe Jupyter notebook output block class namestring-
outputImageClassNameThe Jupyter notebook output image class namestring-
outputOuterClassNameThe Jupyter notebook output outer class namestring-
inputOuterClassNameThe Jupyter notebook input outer class namestring-
outputBorderClassNameThe Jupyter notebook output block left-border class namestring-
inputBorderClassNameThe Jupyter notebook input block left-border class namestring-
outputTableClassNameThe Jupyter notebook output table class namestring-
inputMarkdownBlockClassNameThe Jupyter notebook input markdown class namestring-
inputCodeBlockClassNameThe Jupyter notebook input code class namestring-
inputCodeDarkThemeThe Jupyter notebook input code theme optionbooleanfalse
outputDarkThemeThe Jupyter notebook output code theme optionbooleanfalse
inputMarkdownDarkThemeThe Jupyter notebook input markdown theme optionbooleanfalse
showInputLineNumbersThe Jupyter notebook input code line numbers visibilitybooleanfalse
showOutputLineNumbersThe Jupyter notebook output code line numbers visibilitybooleanfalse
withOnClickThe Jupyter notebook on block click functionalitybooleanfalse
hideCodeBlocksThe Jupyter notebook input code blocks visibilitybooleanfalse
hideMarkdownBlocksThe Jupyter notebook input markdown blocks visibilitybooleanfalse
hideAllOutputsThe Jupyter notebook output (images/tables/code/etc.) blocks visibilitybooleanfalse
hideAllInputsThe Jupyter notebook input (code/markdown) blocks visibilitybooleanfalse
remarkPluginsThe Jupyter notebook remark plugins, see herearray-
rehypePluginsThe Jupyter notebook rehype plugins, see herearray-

License

The React Jupyter Notebook Viewer package is licensed under MIT.

Motivation

I required a Jupyter notebook renderer for React since I was busy on a React/NextJS project. There are a decent amount of packages that could have been used such as react-jupyter-notebook, but in my opinion these packages are not very customizable and some of them are deprecated. Therefore I started working on this idea.

I've mainly focused on the code block part and not the markdown part and this might be an issue in some situations since I've styled the markdown HTML elements myself. That's also one of the reasons I've added the properties remarkPlugins and rehypePlugins in case you'd like to customize it.

Links

1.1.13

3 years ago

1.1.12

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago