Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert notebook with ipylab #102

Open
simbalsyd opened this issue Aug 27, 2022 · 2 comments
Open

Convert notebook with ipylab #102

simbalsyd opened this issue Aug 27, 2022 · 2 comments

Comments

@simbalsyd
Copy link

Hi,

Usually I am using nbconvert to convert a notebook to html. Today I was searching for a way to do it via code from inside the notebook. When searching for it I found ipylab and the command "notebook:export-to-format" but I don't understand how to use it.

From the notebook I did

from ipylab import JupyterFrontEnd
app = JupyterFrontEnd()
app.commands.execute("docmanager:save")
app.commands.execute("notebook:export-to-format")

I get no error messages but also no file.

What I eventually would like to do is something corresponding to
nbconvert --to html --template classic --no-input notebook

Do you have any idea on how to do it?

@jtpio
Copy link
Owner

jtpio commented Aug 28, 2022

Thanks @simbalsyd.

It should be possible to use the following to export the current notebook to HTML:

app.commands.execute('notebook:export-to-format', {
    'format': 'html',
})
ipylab-export-html.mp4

Not sure it would support setting the template or --no-input flag. Or maybe by combining it with https://github.com/timkpaine/jupyterlab_commands.

@anstiwar
Copy link

Thanks a lot @jtpio, this helped me a lot.

Can you also provide an example to provide the location where we can export the file (If it's possible)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants