diff --git a/README.md b/README.md index f2b420c..fcb81f0 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,21 @@ hide_code is a Jupyter notebook extension to selectively hide code, prompts and 3. `jupyter nbextension enable --py hide_code` 4. `jupyter serverextension enable --py hide_code` +## Upgrading with nbextension +1. `pip install hide_code --upgrade` +2. `jupyter nbextension install --py hide_code` + Note: add `--sys-prefix` to `jupyter nbextension` to install into virtualenv or conda environment. -## Upgrading from 0.3.1? -Versions prior to 0.4 were installed by bootstrapping custom.js and jupyter configuration files. Pip uninstall does not remove these files. Upgrade to 0.4, then run `python -c "import hide_code; hide_code.uninstall_bootrapped_files()"`. +## New in 0.5.0 +* Export Reveal.js slides or latex templates. +* Support for nbconvert 5.x+ and notebook 5.x+. ## Documentation Visit the [Wiki](https://github.com/kirbs-/hide_code/wiki). ## Requirements -* Jupyter notebook 4.x+ -* Jupyter nbconvert ~>4.2+ if using nbconvert command line exporting. +* Jupyter notebook ~>5.1 +* Jupyter nbconvert ~>5.0. * pdfkit & [wkhtmltopdf](http://wkhtmltopdf.org/) * Python 2.7 or 3.3+ diff --git a/hide_code/hide_code.js b/hide_code/hide_code.js index 6fe5e73..a8ca502 100644 --- a/hide_code/hide_code.js +++ b/hide_code/hide_code.js @@ -107,40 +107,50 @@ function ($, celltoolbar, Jupyter){ } } + /** + * Export handlers + **/ + + function exportHTML(){ + window.location = exportLink("html"); + Jupyter.notebook.kernel.reconnect(); + } + + function exportPDF(){ + window.location = exportLink("pdf"); + Jupyter.notebook.kernel.reconnect(); + } + + function exportPDFLatex(){ + window.location = exportLink("latexpdf"); + Jupyter.notebook.kernel.reconnect(); + } + /** * Add a toolbar button to toggle visibility of all code cells, input/output prompts, and remove any highlighting for the selected cell. **/ function addHideCodeButtonToToolbar(){ - IPython.toolbar.add_buttons_group([ - { - 'label' : 'Hide/show code', - 'icon' : 'fa-code', - 'callback' : toggleAllPromptsAndCode - }, - { - 'label' : 'Export to HTML', - 'icon' : 'fa-file-text-o', - 'callback' : function (){ - window.location = exportLink("html"); - Jupyter.notebook.kernel.reconnect(); - } - }, - { - 'label' : 'Export to PDF via HTML', - 'icon' : 'fa-file-pdf-o', - 'callback' : function (){ - window.location = exportLink("pdf"); - Jupyter.notebook.kernel.reconnect(); - } - }, - { - 'label' : 'Export to PDF via Latex', - 'icon' : 'fa-file-o', - 'callback' : function (){ - window.location = exportLink("latexpdf"); - Jupyter.notebook.kernel.reconnect(); - } - } + Jupyter.toolbar.add_buttons_group([ + Jupyter.actions.register ({ + 'help': 'Toggle everything', + 'icon': 'fa-code', + 'handler': toggleAllPromptsAndCode + }, 'hide_code:toggle_all'), + Jupyter.actions.register ({ + 'help': 'Export to HTML', + 'icon': 'fa-file-text-o', + 'handler': exportHTML + }, 'hide_code:export_html'), + Jupyter.actions.register ({ + 'help': 'Export to PDF via HTML', + 'icon': 'fa-file-pdf-o', + 'handler': exportPDF + }, 'hide_code:export_pdf'), + Jupyter.actions.register ({ + 'help': 'Export to PDF via Latex', + 'icon': 'fa-file-o', + 'handler': exportPDFLatex + }, 'hide_code:export_pdflatex') ]); } diff --git a/setup.py b/setup.py index d61bf4d..eb45575 100644 --- a/setup.py +++ b/setup.py @@ -91,7 +91,7 @@ # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=['jupyter', 'pdfkit'], + install_requires=['jupyter', 'pdfkit', 'nbconvert>=5.0', 'notebook>=5.1'], # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these