KLM117
KLM117

Reputation: 467

Using nbconvert to hide all input cells?

I have a two cells in a Jupyter notebook, one which defines a function, and one which executes said function (I've provided a simplified function as of now). Currently, I include a bash command within the function to convert this notebook to a html file using nbconvert:

Current output/notebook.ipynb


Cell 1

summary_gen(filepath):

    for summary in Path(filepath).rglob('*.txt'):
        txt= str(txt)

    print(bam)
    !jupyter nbconvert "/path/to/this/notebook.ipynb"



Cell 2

Summary_gen("/path/to/file") 

However, although I can output my entire notebook, my goal is to use nbconvert to output a html which only contains the output of the function, meaning when I run the function, I get a html like so:

Desired output



I think this is possible using some form of:

or even the regex version:

However, I admit I'm not entirely sure how to tag cells, or if there might be a better solution.

As always any help is appreciated!

Upvotes: 1

Views: 2363

Answers (1)

Shunya
Shunya

Reputation: 2484

You can pass the argument --no-input to hide all the input cells in the output document.
You can just use it as:

jupyter nbconvert --no-input notebook.ipynb

You can also add --no-prompt to hide the prompts and have all the cells vertically aligned.

More information of the configurations options in the docs

Upvotes: 2

Related Questions