2

I often export my .ipynb file to .html format. It would be great to know how to remove the 'In []' and 'Out []' part of .ipynb files in Jupyter Notebook or in HTML after being exported to a .html file.

I would like to remove those parts pointed by the arrows

1

4 Answers 4

3

I think this might help you:

jupyter nbconvert --to html --TemplateExporter.exclude_input_prompt=True --TemplateExporter.exclude_output_prompt=True <your_file>.ipynb 

Setting TemplateExporter.exclude_input_prompt=True removes the in [] Similarly TemplateExporter.exclude_output_prompt=True removes the out [] from the generated .html

Sign up to request clarification or add additional context in comments.

1 Comment

Welcome to StackOverflow tour. Please edit your answer and add an explanation about the code you posted. Thank you.
1

This can be simply achieved using --no-prompt flag:

jupyter nbconvert --to html --no-prompt your_notebook.ipynb 

Comments

0
  1. Run Jupyter notebook and download the notebook in the browser: File->Download as->HTML and you will get a html page with code and output.
  2. Open the exported HTML with browser and activate the browser console with key F12
  3. Run following command in the console:

    document.querySelectorAll("div.input").forEach(function(a){a.remove()})

The code removes all input div DOM. Then right mouse button and chose "Save Page As" and Save the "Complete page" (not single page).

You will get a page with an associated folder in windows. Use a trick by zip the html page and then extract to unbind the associated. The folder is useless.

Now it is a single html page without code. You can re-distribute it or print it as PDF.

2 Comments

Hi, this doesn't remove the 'In []' and 'Out []' . Instead, it removes the code. I would like to keep the code but not 'In []' and 'Out []'. Thanks
then I think you should use editor and use find and replace tool.
0

Add the following to the .jp-OutputPrompt and .jp-InputPrompt in the css section of the HTML document

color: transparent !important; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.