Skip to content

Commit

Permalink
Merge pull request #85 from kirbs-/dev
Browse files Browse the repository at this point in the history
v0.5.6 Release
  • Loading branch information
kirbs- committed Oct 19, 2020
2 parents d94b1c5 + 052ffc9 commit 408b0f9
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ hide_code.sublime-workspace
/hide_code/test/.ipynb_checkpoints/*
*.iml
*.idea
# *.ipynb
*.ipynb
*.pdf
*.html s
.vscode
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ python:
# ImportError: Tornado requires an up-to-date SSL module. This means Python 2.7.9+ or 3.4+ (although some distributions
# have backported the necessary changes to older versions).
# - "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
# does not have headers provided, please ask https://launchpad.net/~pypy/+archive/ppa
# maintainers to fix their pypy-dev package.
# - "pypy"
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![PyPI version](https://badge.fury.io/py/hide_code.svg) ![MIT license](https://img.shields.io/github/license/mashape/apistatus.svg)
Release: ![Travis release build](https://travis-ci.org/kirbs-/hide_code.svg?branch=master) Dev: ![Dev Build Status](https://travis-ci.org/kirbs-/hide_code.svg?branch=dev)

hide_code is a Jupyter notebook extension to selectively hide code, prompts and outputs with PDF and HTML exporting support.
hide_code is a Jupyter notebook extension to selectively hide code, prompts and outputs with PDF and HTML exporting support. Check out the demo with [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kirbs-/hide_code/master?filepath=demo.ipynb)

![demo](/images/demo.gif)

Expand All @@ -18,9 +18,22 @@ hide_code is a Jupyter notebook extension to selectively hide code, prompts and

Note: add `--sys-prefix` to `jupyter nbextension` to install into virtualenv or conda environment.

## New in 0.5.0
* Export Reveal.js slides or latex templates.
* Support for nbconvert 5.x+ and notebook 5.x+.
## New in 0.5.3, 0.5.5 and 0.5.6
#### Improvements
* Added Binder demo [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kirbs-/hide_code/master?filepath=demo.ipynb)
* Simplified extension installation. No longer need to use nbextension/serverextension commands after pip install.
* No longer supporting Python 2.7 or . Install hide_code==0.5.2 for Python 2.7.
* 0.5.6 is the last version to support Python versions below 3.7.

#### Bug Fixes
* Fixed latexpdf exporting.
* Changed nbconvert --to hide_code_pdf to use pdfkit.
* Fixed issue exporting notebooks after renaming a notebook.
* Resolved issue exporting notebooks with spaces in notebook name.
* Updated reading file to always use utf-8 encoding. This should resolve non-latin character issues.
* Renamed license file.



## Documentation
Visit the [Wiki](https://github.com/kirbs-/hide_code/wiki).
Expand All @@ -29,4 +42,6 @@ Visit the [Wiki](https://github.com/kirbs-/hide_code/wiki).
* Jupyter notebook ~>5.1
* Jupyter nbconvert ~>5.0.
* pdfkit & [wkhtmltopdf](http://wkhtmltopdf.org/)
* Python 2.7 or 3.3+
* Python 3.4+

![hide_code-hits](https://caspersci.uk.to/cgi-bin/hits.cgi?q=hide_code&style=social&r=https://github.com/kirbs-/hide_code&l=https://caspersci.uk.to/images/tqdm.png&f=https://raw.githubusercontent.com/tqdm/tqdm/master/images/logo.gif)
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Release build
hide_code is an extension for Jupyter/IPython notebooks to selectively hide code, prompts and output. Make a notebook a code free document for exporting or presenting. Documentation at https://github.com/kirbs-/hide_code


.. |hide_code-hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=hide_code&style=social&r=https://github.com/kirbs-/hide_code&l=https://caspersci.uk.to/images/tqdm.png&f=https://raw.githubusercontent.com/tqdm/tqdm/master/images/logo.gif
10 changes: 10 additions & 0 deletions apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
texlive-xetex
xvfb
libfontconfig
wkhtmltopdf
pandoc
texlive-fonts-recommended
texlive-generic-recommended
texlive-latex-extra
texlive-generic-extra
lmodern
9 changes: 4 additions & 5 deletions demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
"hideCode": false,
"hideCode": true,
"hidePrompt": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Goodbye prompts\n"
"Goodbye code\n"
]
}
],
Expand All @@ -37,7 +37,7 @@
"execution_count": 2,
"metadata": {
"hideCode": false,
"hidePrompt": false
"hidePrompt": true
},
"outputs": [
{
Expand Down Expand Up @@ -156,7 +156,6 @@
}
],
"metadata": {
"celltoolbar": "Hide code",
"hide_code_all_hidden": false,
"kernelspec": {
"display_name": "Python 3",
Expand All @@ -173,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.1"
}
},
"nbformat": 4,
Expand Down
Empty file removed environment.yaml
Empty file.
5 changes: 4 additions & 1 deletion hide_code/hide_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ function ($, celltoolbar, Jupyter){

function exportLink(path){
// return window.location.origin + window.location.pathname + "/export/" + path;
return window.location.origin + '/notebooks/' + Jupyter.notebook.notebook_path + "/export/" + path;
// this is a hack to get the base pathname from the url. Need to do this so I can reset the export URLs
// when a notebook is renamed.
var pathname = window.location.pathname.split('/').filter(e=> !Jupyter.notebook.notebook_path.split('/').includes(e)).join('/');
return window.location.origin + pathname + '/' + Jupyter.notebook.notebook_path + "/export/" + path;
}

var hideCodeCallback = ctb.utils.checkbox_ui_generator( 'Hide Code ', hideCodeSetter, hideCodeGetter);
Expand Down
5 changes: 3 additions & 2 deletions hide_code/hide_code_html_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def template_path(self):
`./templates/` so append it to the search path. (see next section)
"""
return super(HideCodeHTMLExporter, self).template_path + [os.path.join(os.path.dirname(__file__), "Templates")]
# return [os.path.join(os.path.dirname(__file__), "Templates")]

# @default('default_template_path')
# def _default_template_path_default(self):
# @default('template_path')
# def _default_template_path(self):
# return os.path.join(os.path.dirname(__file__), "Templates")
14 changes: 14 additions & 0 deletions postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
jupyter nbextension install hide_code --py --sys-prefix
jupyter nbextension enable hide_code --py --sys-prefix
jupyter serverextension enable hide_code --py --sys-prefix

# hack to use allow headless wkhtmltopdf via xvfb on Ubuntu/Debian see:
# https://github.com/fomightez/jupyter_hide_code/blob/master/postBuild
# https://github.com/JazzCore/python-pdfkit/wiki/Using-wkhtmltopdf-without-X-server
cd ~
# enable xvfb with wkhtmltopdf as described here so it will work with pdfkit similar to as shown at https://github.com/JazzCore/python-pdfkit/wiki/Using-wkhtmltopdf-without-X-server and more like how I activated orca with xvfb at https://github.com/fomightez/orca-plotly-binderized/blob/master/postBuild
# When this works, it should allow the test at the last line of the code at https://github.com/JazzCore/python-pdfkit/wiki/Using-wkhtmltopdf-without-X-server , i.e., `wkhtmltopdf http://www.google.com output.pdf`, at least not give that it cannot connect to X display
mkdir -p ~/.local/bin
printf '#!/bin/bash \nxvfb-run --auto-servernum --server-args "-screen 0 640x480x24" /usr/bin/wkhtmltopdf "$@"' > ~/.local/bin/wkhtmltopdf.sh
chmod 777 ~/.local/bin/wkhtmltopdf.sh
ln -s ~/.local/bin/wkhtmltopdf.sh ~/.local/bin/wkhtmltopdf
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hide_code==0.5.5
hide_code==0.5.6
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(self):
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.5.5',
version='0.5.6',

description='A Jupyter notebook extension to hide code, prompts and outputs.',
long_description=long_description,
Expand Down Expand Up @@ -65,9 +65,6 @@ def run(self):
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand All @@ -85,7 +82,12 @@ def run(self):
# 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', 'nbconvert>=5.0', 'notebook>=5.1'],
install_requires=[
'jupyter',
'pdfkit',
'nbconvert>=5.0,<6',
'notebook>=5.1',
'traitlets<5'],

# 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 408b0f9

Please sign in to comment.