File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,37 @@ $ npm install --save react-ipynb-renderer-katex
5454# Usage
5555Just pass an ipynb json object to ` IpynbRenderer ` component.
5656
57+ ## Using ipynb as a string
58+ If you have an ipynb file as a string, you can parse it using ` JSON.parse() ` :
59+
60+ ``` jsx
61+ import { IpynbRenderer } from " react-ipynb-renderer" ;
62+
63+ // Jupyter theme
64+ import " react-ipynb-renderer/dist/styles/monokai.css" ;
65+
66+ export const Component = () => {
67+ const ipynbString = ` {
68+ "cells": [
69+ {
70+ "cell_type": "markdown",
71+ "metadata": {},
72+ "source": ["# Hello World"]
73+ }
74+ ],
75+ "metadata": {},
76+ "nbformat": 4,
77+ "nbformat_minor": 4
78+ }` ;
79+
80+ const ipynb = JSON .parse (ipynbString);
81+
82+ return (
83+ < IpynbRenderer ipynb= {ipynb} / >
84+ );
85+ };
86+ ```
87+
5788## Simplest example
5889
5990### Using react-ipynb-renderer
You can’t perform that action at this time.
0 commit comments