• Stars
    star
    97
  • Rank 336,911 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tools to use a collection of notebooks as 'chapters'

Bookbook converts a set of notebooks in a directory to HTML or PDF, preserving cross references within and between notebooks.

This code is in early development, so use it at your own risk.

Installation

Bookbook requires Python 3.5.

pip install bookbook

To install locally as an editable install, run:

pip install flit
git clone https://github.com/takluyver/bookbook.git
cd bookbook
flit install --symlink

Running bookbook

bookbook expects a directory of notebooks whose names indicate their order. Specifically, the file names must have the form ``x-y.ipynb``, where typically x is a number indicating the order and y is a chapter title; e.g.: 01-introduction.ipynb.

To run bookbook:

python3 -m bookbook.html           # HTML output under html/
python3 -m bookbook.latex [--pdf]  # Latex/PDF output as combined.(tex|pdf)

Add --help to either command for more options.

Chapters and sections

Each top-level header (# xyz in markdown) will be converted to a top-level latex section (a chapter if using the book or report document class). Lower-level headers (##, ###, etc.) are converted to subsections, subsubsections, etc. A latex label will also be inserted for each. The first cell of each notebook must start with a top-level header.

Cross-references

Markdown references will be converted automatically to latex references. For instance, if the markdown contains the hyperlink [02-foo](02-foo.ipynb) and 02-foo.ipynb is a notebook in the same directory, the link will appear as Chapter \ref{sec:02-foo}. The label \label{sec:02-foo} will be inserted at the start of that notebook, so when the latex is compiled to PDF it will appear as Chapter 2.

References to sections within a notebook work similarly. If a notebook contains (in markdown) the section heading ## bar within the notebook starting with top-level header # foo, then the markdown hyperlink [foo](foo.ipynb#bar) will be converted to the latex reference Section \ref{bar} and when compiled to PDF it will be rendered as something like Section 2.1.

Latex formatting

bookbook uses nbconvert under the hood. Custom formatting of latex output can be accomplished by using a template, in the same way as would be done using nbconvert by itself. See the nbconvert documentation for more details.

Examples of projects using bookbook

  • Book on Riemann solvers (in development) by David Ketcheson, Mauricio del Razo, and Randall LeVeque. This example uses a custom nbconvert template and shows how to store your notebooks with no output (for version control) while automatically executing them before running bookbook, so that PDF and HTML versions include the output.

Related tools

If you are writing a book in Jupyter notebooks, you may also find these to be useful:

  • nbopen: open notebooks from the command line without launching a new notebook server. We find it useful to launch a single server in your home directory; then nbopen will use that to open each notebook.
  • nbdime: diff/merge for notebooks; includes terminal or graphical output.
  • nbstripout: remove output from notebooks before committing them.

More Repositories

1

pynsist

Build Windows installers for Python applications
Python
850
star
2

bash_kernel

A bash kernel for IPython
Python
651
star
3

cite2c

Citations in the Jupyter Notebook
JavaScript
313
star
4

nbopen

Open a Jupyter notebook in the best available server
Python
293
star
5

igo

(Unmaintained) Go Kernel for Jupyter
Go
123
star
6

nbparameterise

Programmatically replace input values in a notebook before running it
Python
112
star
7

mobilechelonian

Turtles on a notebook
JavaScript
99
star
8

pyxdg

PyXDG provides Python implementations of various freedesktop.org specifications. This is the Giithub mirror.
Python
78
star
9

entrypoints

Discover and load entry points from installed packages
Python
72
star
10

astsearch

Intelligently search in Python code
Python
66
star
11

Unidecode

A python module to reduce Unicode to a 'good enough' ASCII representation (outdated Github copy)
Python
29
star
12

ubit_kernel

Jupyter kernel for the BBC micro:bit
Python
23
star
13

weatbag

Written by Everyone Altogether, The Big Adventure Game
Python
21
star
14

ZeroRPC

Simple RPC for Python programs, using ZeroMQ
Python
20
star
15

jupyter-intro-xfel-jan17

Introduction to Jupyter Notebook
Jupyter Notebook
18
star
16

astcheck

Check Python ASTs against templates
Python
17
star
17

tabipy

Display tables in IPython
Python
17
star
18

reversion

Easily update version numbers across your project
Python
16
star
19

backcall

Backwards compatible callback APIs
Python
16
star
20

py-nsis-template

Template for a Python application installer
Shell
15
star
21

jupyter_kernel_mgmt

Experimental new kernel management framework for Jupyter
Python
15
star
22

wheel2conda

Convert pure-Python wheels to conda packages (experimental)
Python
11
star
23

nbconvert-reportlab

Jupyter Notebook
11
star
24

nbexplode

Explode a notebook into a directory of files, and recombine it to a .ipynb
Python
11
star
25

requests_download

Download to a local file using requests
Python
10
star
26

flonda

Conda packages from flit information
Python
10
star
27

pygame

Mirror of pygame repo
C
10
star
28

pandawash

Magic commands to quickly & transparently clean up data
Python
9
star
29

customising-nbconvert

Talk for PyData London 2016
HTML
8
star
30

europython-2017-talk

Jupyter Notebooks for Teaching and Learning
7
star
31

pygame-flatpak-test

Flatpak packaging of pygame games (experimental)
Python
7
star
32

recombinecm

Separating & recombining Jupyter notebook storage, to version control without outputs
Python
7
star
33

pyqt-app-template

Cookiecutter template for a PyQt4 application
Python
6
star
34

hello_jupyter_proxy

A minimal example server to run with jupyter-server-proxy
Python
6
star
35

redsnail

The command line that shows you where you are
JavaScript
5
star
36

wheeldex

Indexing Python wheels
Python
5
star
37

jupyter_protocol

Experimental
Python
5
star
38

bisect-demo

Demoing git bisect
Python
5
star
39

intreehooks

Load a PEP 517 backend from inside the source tree
Python
4
star
40

ucb-ipython-intro

IPython intro lecture at UC Berkeley, 2 March 2015
Python
4
star
41

tox_appveyor

Select 32 or 64-bit Python for Tox on Appveyor
Python
4
star
42

r2_kernel

R wrapper kernel for IPython
Python
4
star
43

calcurust

A sample Jupyter kernel in Rust
Rust
3
star
44

ARE

An alternative R environment for Linux
Python
3
star
45

damnpth

Forcibly fix setuptools' .pth files
Python
3
star
46

euroscipy-2017-nbval

Nbval talk at Euroscipy 2017
Jupyter Notebook
3
star
47

Zantedeschia

Experimental ZMQ integration with asyncio
Python
2
star
48

jupyter_ssh_kernels

Python
2
star
49

hdf5-units

WIP specification for recording units in HDF5 files
2
star
50

altwidgets-prototype

JavaScript
2
star
51

importtracer

Track Python imports
Python
2
star
52

pyqt4_windows_whl

Python
2
star
53

sqlite-glance

Inspect an SQLite database in the terminal
Rust
2
star
54

cell2function

IPython extension to convert a cell to a function
Python
2
star
55

tornado_xstatic

Utilities for using XStatic in Tornado applications
Python
2
star
56

ipython-sfpython-feb-2015

Talk about IPython for SFPython, February 2015
1
star
57

XStatic-termjs

A terminal written in Javascript, packaged for Python
JavaScript
1
star
58

flit_install_py2

Shim to install packages using flit metadata on Python 2
Python
1
star
59

deskent

Find and inspect .desktop files
Rust
1
star
60

installmod

Install a Python package using conda or pip as appropriate
Python
1
star
61

jupyter_docker_kernels

Experimental docker kernels for Jupyter
Python
1
star
62

cern-jupyter-presentation

Presentation about Jupyter, 10 Dec 2015 at CERN
Jupyter Notebook
1
star
63

spotting-stat-claims

Fullfact hackathon - identifying statistical claims
Jupyter Notebook
1
star
64

nbhtml

Save & load Jupyter notebooks as HTML
HTML
1
star
65

blog

Python
1
star
66

aiokernel

Experimental asyncio-based Python kernel for IPython
Python
1
star