Skip to content

Commit

Permalink
Fixed toolbar buttons showing help text.
Browse files Browse the repository at this point in the history
Added notebook >= 5.1 and nbconvert >=5.0 dependency.
Updated README.
  • Loading branch information
kirbs- committed Oct 7, 2017
1 parent de352ca commit 06695a5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 35 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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+
70 changes: 40 additions & 30 deletions hide_code/hide_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
]);
}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06695a5

Please sign in to comment.