Skip to content

Instantly share code, notes, and snippets.

@DGrady
Last active September 25, 2017 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DGrady/cc85545b0128118b1660b52c25bb3ba1 to your computer and use it in GitHub Desktop.
Save DGrady/cc85545b0128118b1660b52c25bb3ba1 to your computer and use it in GitHub Desktop.
A Python script to remove input cells from a Jupyter-notebook-generated HTML file
"""
Remove the input cells from an HTML document generated from a Jupyter notebook
Reads from either STDIN or the named file, and writes to STDOUT
"""
import fileinput
from bs4 import BeautifulSoup
text = "".join(fileinput.input())
doc = BeautifulSoup(text, 'html.parser')
[x.extract() for x in doc.select('div.input')]
print(str(doc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment