Skip to content

Instantly share code, notes, and snippets.

@hamelsmu
Last active January 22, 2020 20:01
Show Gist options
  • Save hamelsmu/74487c67116bc5c202e2733717f6eb80 to your computer and use it in GitHub Desktop.
Save hamelsmu/74487c67116bc5c202e2733717f6eb80 to your computer and use it in GitHub Desktop.
Monkey Patch nbdev for Jupyter Blog Posts
from nbdev import export2html
from nbdev.export2html import Config, Path, _re_digits
## Monkey Patch Nbdev For Jupyter Blog Posts ##
def _nb2htmlfname(nb_path, dest):
if dest is None: dest = Config().doc_path
return Path(dest)/_re_digits.sub('', nb_path.with_suffix('.md').name)
## apply monkey patch
export2html._nb2htmlfname = _nb2htmlfname
# convert notebooks to Jekyll compliant blog posts
notebook2html(fname='/path/*.ipynb', dest='/_posts')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment