Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Oct 3, 2024
1 parent 87a839b commit a0b4a05
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,26 @@ can find package manager specific guidelines on

## How to use

Fill me in please! Don’t forget code examples:
Call a Jupyter notebook with the `nb2classic.core.render_nb` function. It will convert the notebook into FT Components. You will need to have the `MarkdownJS()` and `HighlightJS()` set in the FastHTML hdrs.

Here's an example that uses `demo.ipynb`, which is in the root of this project.

``` python
1+1
from nb2fasthtml.core import *
from fasthtml.common import *

hdrs = [
MarkdownJS(),
HighlightJS(langs=['python', 'javascript', 'html', 'css',]),
]

app, rt = fast_app(hdrs=hdrs)

@rt
def index():
return render_nb('demo.ipynb')

serve()
```

2
The `render_nb()` function can be configured to work with other layout libraries such as fh-frankenui.
15 changes: 15 additions & 0 deletions test_pico2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from nb2fasthtml.core import *
from fasthtml.common import *

hdrs = [
MarkdownJS(),
HighlightJS(langs=['python', 'javascript', 'html', 'css',]),
]

app, rt = fast_app(hdrs=hdrs)

@rt
def index():
return render_nb('demo.ipynb')

serve()

0 comments on commit a0b4a05

Please sign in to comment.