GithubHelp home page GithubHelp logo

chrisjsewell / ipypublish Goto Github PK

View Code? Open in Web Editor NEW
223.0 15.0 37.0 48.9 MB

A workflow for creating and editing publication ready scientific reports and presentations, from one or more Jupyter Notebooks, without leaving the browser!

Home Page: http://ipypublish.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 11.56% TeX 2.34% HTML 63.01% Shell 0.01% Python 4.34% JavaScript 18.61% CSS 0.06% Makefile 0.04% Batchfile 0.04%
python jupyter-notebook nbconvert latex sphinx

ipypublish's Introduction

IPyPublish

A program for creating and editing publication ready scientific reports and presentations, from one or more Jupyter Notebooks.

Documentation: ipypublish.readthedocs.io

CI Status Coverage Status PyPI DOI Conda Code Style

Attention: This package is still maintained, but it is envisaged that it will eventually be superceeded by the Executable Book Project toolchain. So definitely also check that out, and feedback any improvement suggestions! ๐Ÿ˜€

Conversion Process

For an example of the potential input/output, see: Example.ipynb, Example.pdf, Example.html and Example.slides.html.

Or, for a practical example of the ipypublish capability, see these documents on Atomic 3D Visualisation: Notebook, PDF, HTML or Reveal.JS slideshow.

Design Philosophy

In essence, the dream is to have the ultimate hybrid of Jupyter Notebook, WYSIWYG editor (e.g. MS Word) and document preparation system (e.g. TexMaker), being able to:

  • Dynamically (and reproducibly) explore data, run code and output the results
  • Dynamically edit and visualise the basic components of the document (text, math, figures, tables, references, citations, etc).
  • Have precise control over what elements are output to the final document and how they are layed out and typeset.
    • Also be able to output the same source document to different layouts and formats (pdf, html,presentation slides, etc).

Workflow

  1. Create a notebook with some content!
  2. optionally create a .bib file and external images
  3. Adjust the notebook and cell metadata.
  4. install ipypublish and run the nbpublish for either the specific notebook, or a folder containing multiple notebooks.
  5. A converted folder will be created, into which final .tex .pdf and .html files will be output, named by the notebook or folder input

The default latex template outputs all markdown cells (unless tagged latex_ignore), and then only code and output cells with latex metadata tags. See Example.ipynb, Example.pdf, Example.html and Example.slides.html for examples of the potential input and output.

WorkFlow Example

See the project site for more info!

Acknowledgements

IPyPublish is built as an extension to nbconvert.

I also took strong influence from:

ipypublish's People

Contributors

chrisjsewell avatar katie-jones avatar mgeier avatar oliverevans96 avatar parmentelat avatar phelps-sg avatar stonebig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipypublish's Issues

add text label

For output text/stream text/error messages/tracebacks, with option to color by code language, wrap in box, maybe different color to code

Make sure its added to latex, html and slides

more tests

  • testing for notebooks with internal/external files
  • testing that specific content has been output in the files (or at least simple assert in for keywords/phrases)
  • write some tests for the individual preprocessors
  • test web serving (and thus nbpresent)

.tex file has no document content

Hello Chris,
Thanks for your help with the installation issue. All good now.

I am still having problems with content generation.
(1) With a simple notebook as described below, I only get the markdown. If using the -f latex_standard_article it works just aside some very minor formatting issues.
(2) With a notebook of mine, it is not generating any \document content in the .tex file, only header/config details.

There is something not happening on the nbconvert phase.

Please let me know if you can see between the lines or if you need any specific information from my environment.

Thanks in advance.

1

Untitled.tex

. . .
	\begin{document}
\section{Chart 2}\label{chart-2}
	\end{document}

Untitled.ipynb

In [1] from ipypublish.scripts.ipynb_latex_setup import *
In [2] %matplotlib inline
       import matplotlib.pyplot as plt
In [3] for i in range(10):
       print(i)
0
1
2
3
4
5
6
7
8
9
       Chart 2.    # <- Markdown
In [4] plt.plot([1,2,3], [4,2,7])
       plt.show()
(actual chart)

2 $ nbpublish -pdf --pdf-debug notebook.ipynb

notebook.tex

. . .
	\begin{document}
	\end{document}

nppub.log

INFO:main:started ipypublish at Wed Jul 19 10:52:36 2017
INFO:main:logging to: /Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted/20-EDA-tbl_FA_360_Full.nbpub.log
INFO:main:running for ipynb(s) at: 20-EDA-tbl_FA_360_Full.ipynb
INFO:main:with conversion: latex_ipypublish_main
INFO:nbmerge:Reading notebook
INFO:main:getting output format from exporter plugin
INFO:nbexport:running nbconvert
INFO:latex_doc:resolving external file paths in latex_doc metadata to: 20-EDA-tbl_FA_360_Full.ipynb
INFO:main:outputting converted file to: /Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted/20-EDA-tbl_FA_360_Full.tex
INFO:main:dumping external files to: /Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted/20-EDA-tbl_FA_360_Full_files
INFO:main:running pdf conversion
INFO:pdfexport:running: latexmk -bibtex -pdf <outpath>
INFO:pdfexport:latexmk: Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
INFO:pdfexport:latexmk: Rule 'pdflatex': Rules & subrules not known to be previously run:
INFO:pdfexport:latexmk: pdflatex
INFO:pdfexport:latexmk: Rule 'pdflatex': The following rules & subrules became out-of-date:
INFO:pdfexport:latexmk: 'pdflatex'
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: Run number 1 of rule 'pdflatex'
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: Running 'pdflatex  -recorder  "/Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted/20-EDA-tbl_FA_360_Full.tex"'
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: Latexmk: applying rule 'pdflatex'...
INFO:pdfexport:latexmk: This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
INFO:pdfexport:latexmk: restricted \write18 enabled.
INFO:pdfexport:latexmk: entering extended mode
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: (/Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted
INFO:pdfexport:latexmk: /20-EDA-tbl_FA_360_Full.tex
INFO:pdfexport:latexmk: LaTeX2e <2017-04-15>
INFO:pdfexport:latexmk: Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
...
INFO:pdfexport:latexmk: Package scrlayer-scrpage Warning: Very small head height detected!
INFO:pdfexport:latexmk: (scrlayer-scrpage)                Using scrlayer-scrpage the head height
INFO:pdfexport:latexmk: (scrlayer-scrpage)                should be at least \baselineskip, which is
INFO:pdfexport:latexmk: (scrlayer-scrpage)                12.0pt currently.
INFO:pdfexport:latexmk: (scrlayer-scrpage)                But head height is currently 0.0pt only.
INFO:pdfexport:latexmk: (scrlayer-scrpage)                You may use
INFO:pdfexport:latexmk: (scrlayer-scrpage)                geometry option `head=12.0pt'
INFO:pdfexport:latexmk: (scrlayer-scrpage)                to avoid this warning.
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: *geometry* driver: auto-detecting
INFO:pdfexport:latexmk: *geometry* detected driver: pdftex
INFO:pdfexport:latexmk: (./20-EDA-tbl_FA_360_Full.aux)
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: Package rerunfilecheck Warning: File `20-EDA-tbl_FA_360_Full.out' has changed.
INFO:pdfexport:latexmk: (rerunfilecheck)                Rerun to get outlines right
INFO:pdfexport:latexmk: (rerunfilecheck)                or use package `bookmark'.
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: )
INFO:pdfexport:latexmk: No pages of output.          <<<<<<<<<<
INFO:pdfexport:latexmk: Transcript written on 20-EDA-tbl_FA_360_Full.log.
INFO:pdfexport:latexmk: Latexmk: References changed.
INFO:pdfexport:latexmk: Latexmk: Log file says no output from latex          <<<<<<<<<<
INFO:pdfexport:latexmk: Latexmk: For rule 'pdflatex', no output was made          <<<<<<<<<<
INFO:pdfexport:latexmk: Rule 'pdflatex': File changes, etc:
INFO:pdfexport:latexmk: Changed files, or newly in use since previous run(s):
INFO:pdfexport:latexmk: '20-EDA-tbl_FA_360_Full.aux'
INFO:pdfexport:latexmk: '20-EDA-tbl_FA_360_Full.out'
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: Run number 2 of rule 'pdflatex'
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: Running 'pdflatex  -recorder  "/Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted/20-EDA-tbl_FA_360_Full.tex"'
INFO:pdfexport:latexmk: ------------
INFO:pdfexport:latexmk: === TeX engine is 'pdfTeX'
INFO:pdfexport:latexmk: Latexmk: applying rule 'pdflatex'...
INFO:pdfexport:latexmk: This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
INFO:pdfexport:latexmk: restricted \write18 enabled.
INFO:pdfexport:latexmk: entering extended mode
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: (/Users/angeloklin/Documents/Immersive/JLL/Transaction Analytics/code/converted
INFO:pdfexport:latexmk: /20-EDA-tbl_FA_360_Full.tex
INFO:pdfexport:latexmk: LaTeX2e <2017-04-15>
INFO:pdfexport:latexmk: Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
...
INFO:pdfexport:latexmk: *geometry* driver: auto-detecting
INFO:pdfexport:latexmk: *geometry* detected driver: pdftex
INFO:pdfexport:latexmk: (./20-EDA-tbl_FA_360_Full.aux) )
INFO:pdfexport:latexmk: No pages of output.
INFO:pdfexport:latexmk: Transcript written on 20-EDA-tbl_FA_360_Full.log.
INFO:pdfexport:latexmk: Latexmk: Log file says no output from latex
INFO:pdfexport:latexmk: Latexmk: For rule 'pdflatex', no output was made
INFO:pdfexport:latexmk: Failure to make '20-EDA-tbl_FA_360_Full.pdf'
INFO:pdfexport:latexmk: Latexmk: Use the -f option to force complete processing,
INFO:pdfexport:latexmk: unless error was exceeding maximum runs of latex/pdflatex.
INFO:pdfexport:latexmk: === TeX engine is 'pdfTeX'
INFO:pdfexport:latexmk: Latexmk: Errors, so I did not complete making targets          <<<<<<<<<<
Traceback (most recent call last):
  File "/Users/angeloklin/anaconda2/bin/nbpublish", line 131, in <module>
    nbpublish(filepath, **options)   
  File "/Users/angeloklin/anaconda2/bin/nbpublish", line 64, in nbpublish
    create_pdf=create_pdf, pdf_in_temp=pdf_in_temp, pdf_debug=pdf_debug) 
  File "/Users/angeloklin/anaconda2/lib/python2.7/site-packages/ipypublish/main.py", line 148, in publish
    raise RuntimeError('the pdf export failed, try running with pdf_debug=True')
RuntimeError: the pdf export failed, try running with pdf_debug=True
ERROR:pdfexport:pdf conversion failed: Try running with pdf_debug=True
ERROR:main:pdf export returned false, try running with pdf_debug=True

conda / pip environments

$ conda list | grep -E "(nb|pub)"
ipypublish                0.4.1                     <pip>
nb_anacondacloud          1.2.0                    py27_0  
nb_conda                  2.0.0                    py27_0  
nb_conda_kernels          2.0.0                    py27_0  
nbconvert                 5.1.1                    py27_0  
nbconvert                 5.2.1                     <pip>
nbformat                  4.3.0                     <pip>
nbformat                  4.3.0                    py27_0  
nbpresent                 3.0.2                    py27_0  
widgetsnbextension        2.0.0                    py27_0  

$ pip list | grep -E "(nb|pub)"
ipypublish (0.4.1)
nb-anacondacloud (1.2.0)
nb-conda (2.0.0)
nb-conda-kernels (2.0.0)
nbconvert (5.2.1)
nbformat (4.3.0)
nbpresent (3.0.2)
widgetsnbextension (2.0.0)

move toc2 js/css internally

rather than calling externally, which a) is vulnerable to changes at source and b) doesn't allow for offline use

Title page: "supervisors" looks off with multiple names

It would be nice if each supervisor's name appeared on separate lines on the title page. In the example notebook the names are exactly the right length to have this happen, but otherwise you can end up with their names oddly spaced, like this:

image

Add Zotero CSL exporter for markdown citation markup

Citations like this

<cite data-cite="kirkeminde_thermodynamic_2012">(Kirkeminde, 2012)</cite> 

are sometimes desirable for online notebook presentations. Zotero can be made to produce them using CSL, if not with stable BibTex keys (see #2 )

nbpublish and nbpresent scripts not found on Windows

I needed to manually add "nbpublish.bat" and "nbpresent.bat" files to my "anaconda3\Scripts" folder to get the command line tools of the same names to be recognized. They consisted of the following code:

python.exe %~dp0nbpublish %*
and
python.exe %~dp0nbpresent %*

Should be simple to implement this on installation.

HTML Export Support for Interactive Plots

Firstly, thanks for the great tool. I have a notebook with plots generated via Holoviews which uses Bokeh as a backend. The plots come out fine (and retain interactive capacity) if I use standard nbconvert.

jupyter nbconvert --to html test.ipynb

However, nbpublish won't display them if I use any of the html options (including html_standard).

Fix OSX testing on travis

Currently move to allowed failures but should move back.
python now appears to be preinstalled on osx builds, but this has currently broken my setup for installation

Resolution of multiple tags (e.g. table=true and equation=true)

@chrisjsewell,

Another error I have been experiencing with the new release (on a guess base) is related to Latex-renderized outputs. In some cells, I print symbolic expressions with the fancier output brought me by Sympy's init_printing() function.

So far, this was running smoothly, but now, not only the expressions are being printed wrongly, but also a bunch of errors are being launched like this excerpt:

INFO:pdfexport:latexmk: ! Missing $ inserted.
INFO:pdfexport:latexmk: <inserted text>
INFO:pdfexport:latexmk: $
INFO:pdfexport:latexmk: l.1536 ...ght)^{2} \left(x_{0} - x_{2}\right)^{2}}
INFO:pdfexport:latexmk: + \frac{1.0 dy_{1} \left(...
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: ? ! Missing $ inserted.
INFO:pdfexport:latexmk: <inserted text>
INFO:pdfexport:latexmk: $
INFO:pdfexport:latexmk: l.1536 ...ght)^{2} \left(x_{0} - x_{2}\right)^{2}}
INFO:pdfexport:latexmk: + \frac{1.0 dy_{1} \left(...
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: ? ! Missing $ inserted.
INFO:pdfexport:latexmk: <inserted text>
INFO:pdfexport:latexmk: $
INFO:pdfexport:latexmk: l.1536 ...ght)^{2} \left(x_{0} - x_{2}\right)^{2}}
INFO:pdfexport:latexmk: + \frac{1.0 dy_{1} \left(...
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: ? ! Extra }, or forgotten $.
INFO:pdfexport:latexmk: \frac  #1#2->{\begingroup #1\endgroup \@@over #2}
INFO:pdfexport:latexmk: 
INFO:pdfexport:latexmk: l.1536 ...ght)^{2} \left(x_{0} - x_{2}\right)^{2}}
INFO:pdfexport:latexmk: + \frac{1.0 dy_{1} \left(...

The expressions are a bit long, in fact, but they do not match on the .ipynb and the .pdf produced compiled with ipypublish_all flag. Below, two SSs for comparison:

.ipynb
screen shot 2017-08-06 at 22 10 00

.pdf
screen shot 2017-08-06 at 21 58 49

Some clue about this one?

Dealing with unicode

Hello Chris,

I had to make some more change. I know you said I could make a pull request, but I will just add it here.

./ipypublish/main.py 

8 import codecs

127    #with open(outpath, "w") as fh:
128    with codecs.open(outpath, "w", encoding='utf-8') as fh:

The original problem was related to:

INFO:main:outputting converted file to: ./code/converted/Untitled.tex
Traceback (most recent call last):
  File "/Users/angeloklin/anaconda2/bin/nbpublish", line 138, in <module>
    nbpublish(filepath, **options)   
  File "/Users/angeloklin/anaconda2/bin/nbpublish", line 64, in nbpublish
    create_pdf=create_pdf, pdf_in_temp=pdf_in_temp, pdf_debug=pdf_debug) 
  File "/Users/angeloklin/anaconda2/lib/python2.7/site-packages/ipypublish/main.py", line 127, in publish
    fh.write(body)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc9' in position 19437: ordinal not in range(128)

Here is some code you can test:

import regex
import numpy as np
import pandas as pd

%matplotlib inline
import matplotlib as mpl
mpl.rcParams['axes.formatter.limits'] = (-11, 11)
mpl.rcParams['axes.grid'] = True
mpl.rcParams['figure.autolayout'] = True
mpl.rcParams['figure.figsize'] = (15, 5)
mpl.rcParams['hist.bins'] = 80

import matplotlib.pyplot as plt
plt.ioff()

from IPython.display import display
from IPython.display import Markdown
from IPython.display import Image
df = pd.DataFrame({'A': [u'CAFร‰-01', u'CAFร‰-02'], 'X': [1, 2]})
title_1 = 'main_title'
title_2 = regex.sub('_', r'\_', title_1)
display(Markdown('# ' + title_1))
latex = df.to_latex(index=False)
html = df.to_html(index=False)
meta = {'ipub':{'table':{'caption':title_2,'label':'table:tlabel%d' % 1,'placement':'H'}}}
display({'text/latex': latex, 'text/html': html}, raw=True, metadata=meta)
ind = np.arange(2)
counts = df.X
values = df.A

img = 'test.png'
plt.figure()
plt.bar(ind, counts, zorder=3)
plt.title(title_1)
plt.xticks(ind, values, horizontalalignment='right', rotation=45, zorder=0)
plt.savefig(img)
meta = {'ipub':{'figure':{'caption':title_2,'label':'figure:flabel%d' % 1,'placement':'H'}}}
display(Image(img), metadata=meta)
plt.close()

Data Storage/Access/Manipulation

Add a section on best-practices for storing, accessing and manipulating data

A goal for scientific publishing is automated reproducibility of analyses, which the Jupyter notebook excels at. But, more than that, it should be possible to efficiently reproduce the analysis with different data sets. This entails having one point of access to a data set within the notebook, rather than having copy-pasted data into variables, i.e. this:

data = read_in_data('data_key')
variable1 = data.key1
variable2 = data.key2
...

rather than this:

variable1 = 12345
variable2 = 'something'
...

The best-practice for this (in my opinion) is to use the JSON format (as long as the data isn't relational), because it is:

  • applicable for any data structure
  • lightweight and easy to read and edit
  • has a simple read/write mapping to python objects (using json)
  • widely used (especially in web technologies)

A good way to store multiple bits of JSON data is in a mongoDB and accessing it via pymongo. This will also make it easy to move all the data to a cloud server at a later time, if required.

conda install pymongo

But, if the data is coming from files output from different simulation or experimental code, where the user has no control of the output format. Then writing JSON parsers may be the way to go, and this is where jsonextended comes in, which implements:

  • a lightweight plugin system to define bespoke classes for parsing different file extensions and data types.

  • a 'lazy loader' for treating an entire directory structure as a nested dictionary.

    from jsonextended import plugins, edict
    plugins.load_plugins_dir('path/to/folder_of_parsers','parsers')
    data = edict.LazyLoad('path/to/data')
    variable1 = data.folder1.file1_json.key1
    variable2 = data[['folder1','file1.json','key2']]
    variable3 = data[['folder1','file2.csv','key1']]
    variable4 = data[['folder2','subfolder1','file3.other','key1']]
    ...

Error with ipub:institution after update to version 0.6.2

@chrisjsewell,

After updating to version 0.6.2, I have experienced an error that I did not have before:

It looks like something was left misplaced in this release. I can assure that this has to do with the entry

ipub: { 
"institution": "name",
}

but I have not hunted where the bug is. To me, each character of my institution name is now appearing written vertically (one below the other) and leaking out to the second page. My log file shows up lots of this:

INFO:pdfexport:latexmk: ! LaTeX Error: There's no line here to end.
INFO:pdfexport:latexmk:
INFO:pdfexport:latexmk: See the LaTeX manual or LaTeX Companion for explanation.
INFO:pdfexport:latexmk: Type  H <return>  for immediate help.
INFO:pdfexport:latexmk: ...
INFO:pdfexport:latexmk:
INFO:pdfexport:latexmk: l.447 ^^I^^I  \LARGE{ }\\

See screenshot below:

screen shot 2017-08-06 at 21 48 03

improve visualisation/formatting of latex in the notebook

This has previously been achieved (to some extent), as jupyter notebook extension, by jupyter_latex_envs. But, at present, it doesn't appear to have been updated for notebook 5.0 and was quite buggy when I tried it out (e.g. sometimes altering the text and pressing shift-Enter, the text reverted to back its initial value)

windows 10, python 3.5, unicodeencodeerror

C:\Python\Python35_64b\Scripts>python nbpublish.py -f nb_ipypublish_all -o C:\Users\denis\Dropbox\nau_course\lecture-02-pydata C:\Users\denis\Dropbox\nau_course\lecture-02-pydata\WhirlwindTourOfPython
INFO:main:started ipypublish at Mon Sep  4 11:57:50 2017
INFO:main:logging to: C:\Users\denis\Dropbox\nau_course\lecture-02-pydata\WhirlwindTourOfPython.nbpub.log
INFO:main:running for ipynb(s) at: C:\Users\denis\Dropbox\nau_course\lecture-02-pydata\WhirlwindTourOfPython
INFO:main:with conversion: nb_ipypublish_all
INFO:nbmerge:Merging all notebooks in directory
INFO:main:getting output format from exporter plugin
INFO:nbexport:running nbconvert
WARNING:configurable:Config option `filters` not recognized by `MyExporter`.
INFO:latex_doc_defaults:adding ipub defaults to notebook
INFO:main:outputting converted file to: C:\Users\denis\Dropbox\nau_course\lecture-02-pydata\WhirlwindTourOfPython.ipynb
Traceback (most recent call last):
  File "nbpublish.py", line 142, in <module>
    nbpublish(filepath, **options)
  File "nbpublish.py", line 66, in nbpublish
    create_pdf=create_pdf, pdf_in_temp=pdf_in_temp, pdf_debug=pdf_debug)
  File "C:\Python\Python35_64b\lib\site-packages\ipypublish\main.py", line 129, in publish
    fh.write(body)
  File "C:\Python\Python35_64b\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2010' in position 7108: character maps to <undefined>

C:\Python\Python35_64b\Scripts>

PEP8 compliance

There are a lot of trailing whitespace and long lines in the code in violation of PEP8.

This is bad because it confuses the crap out of my IDE, which has automatic PEP8 linking via Flake8, and the trailing whitespace makes for noisy patches with lots of trivial whitespace changes.

I am happy to submit a PR which fixes all whitespace issues, but I'll have to wait until @chrisjsewell goes to sleep, since the patch won't apply at the current rate of updates ;-)

Simpler plugin registry

(Sorry for the barrage of issues. Hopefully they will encourage me to submit PRs implementing the good ones)

Looking at the plugin system here, it seems to be solving a similar problem to many other python projects (markdown, Docutils, Django...) where plugins are defined. Those systems use a "register" pattern, where it's the plugins' job to announce their existence to the app on import. This requires a lot less code; you just keep a dictionary somewhere full of plugin names and don't worry about file paths. This would probably be simpler than the "add_directory" thing and avoid having to mess around with importlib in a python2/3-friendly way, which is painful.

add latex_figure tag for markdown input cells with linked file

So that all pictures don't have to be stored in the notebook, which could make the merged pretty notebook pretty massive (how big would it have to be to break nbconvert/pandoc/mklatex?) for a whole thesis.

  • look for ![](*) regex
  • if text on line above or below, treat that as the caption
  • resolve link location.
  • have extra tags for controlling size (since can't be done using markdown and pandoc strips html tags)

Installing problems

Hello Chris,
Thanks for your work and sharing this package.

I am having problems installing it. Here is what I tried:

Install

Environment

$ uname -a  # macOS Sierra latest version
Darwin MacBook-Pro.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
$ python -V
Python 2.7.13 :: Anaconda 4.4.0 (x86_64)

1) conda

There is no conda package

2) pip

# it only install version 0.0.1
$ pip install ipypublish
Successfully installed docrep-0.1.2 funcargparse-0.1.2 ipypublish-0.0.1

$ conda list | grep pub
ipypublish                0.0.1                     <pip>

$ pip install --upgrade ipypublish
OSError: [Errno 2] No such file or directory: '/Users/user/anaconda2/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg

$ pip install ~/Downloads/ipypublish-0.3.0-py3-none-any.whl 
ipypublish-0.3.0-py3-none-any.whl is not a supported wheel on this platform.

$ pip search ipypublish
ipypublish (0.3.0)  - A workflow for creating and editing publication ready scientific reports, from one or more Jupyter Notebooks
INSTALLED: 0.0.1
LATEST:    0.3.0

$ pip install 'ipypublish==0.3.0'
Collecting ipypublish==0.3.0
Could not find a version that satisfies the requirement ipypublish==0.3.0 (from versions: 0.0.1) No matching distribution found for ipypublish==0.3.0

3) from source

$ pip install -e git+https://github.com/chrisjsewell/ipypublish.git#egg=ipypublish
. . .
Installing collected packages: ipypublish
Running setup.py develop for ipypublish
Successfully installed ipypublish

$ python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to ipypublish.egg-info/requires.txt
writing ipypublish.egg-info/PKG-INFO
writing top-level names to ipypublish.egg-info/top_level.txt
writing dependency_links to ipypublish.egg-info/dependency_links.txt
reading manifest file 'ipypublish.egg-info/SOURCES.txt'
writing manifest file 'ipypublish.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/ipypublish
copying ipypublish/__init__.py -> build/lib/ipypublish
copying ipypublish/main.py -> build/lib/ipypublish
copying ipypublish/test_main.py -> build/lib/ipypublish
copying ipypublish/utils.py -> build/lib/ipypublish
creating build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/__init__.py -> build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/html_ipypublish.py -> build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/html_standard.py -> build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/latex_ipypublish_main.py -> build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/latex_standard_article.py -> build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/slides_ipypublish.py -> build/lib/ipypublish/export_plugins
copying ipypublish/export_plugins/slides_standard.py -> build/lib/ipypublish/export_plugins
creating build/lib/ipypublish/html
copying ipypublish/html/__init__.py -> build/lib/ipypublish/html
copying ipypublish/html/create_tpl.py -> build/lib/ipypublish/html
creating build/lib/ipypublish/latex
copying ipypublish/latex/__init__.py -> build/lib/ipypublish/latex
copying ipypublish/latex/create_tplx.py -> build/lib/ipypublish/latex
creating build/lib/ipypublish/preprocessors
copying ipypublish/preprocessors/__init__.py -> build/lib/ipypublish/preprocessors
copying ipypublish/preprocessors/crop_cells.py -> build/lib/ipypublish/preprocessors
copying ipypublish/preprocessors/latex_doc.py -> build/lib/ipypublish/preprocessors
copying ipypublish/preprocessors/latextags_to_html.py -> build/lib/ipypublish/preprocessors
creating build/lib/ipypublish/scripts
copying ipypublish/scripts/__init__.py -> build/lib/ipypublish/scripts
copying ipypublish/scripts/export_plugins.py -> build/lib/ipypublish/scripts
copying ipypublish/scripts/ipynb_latex_setup.py -> build/lib/ipypublish/scripts
copying ipypublish/scripts/nbexport.py -> build/lib/ipypublish/scripts
copying ipypublish/scripts/nbmerge.py -> build/lib/ipypublish/scripts
copying ipypublish/scripts/pdfexport.py -> build/lib/ipypublish/scripts
copying ipypublish/scripts/reveal_serve.py -> build/lib/ipypublish/scripts
creating build/lib/ipypublish/html/ipypublish
copying ipypublish/html/ipypublish/__init__.py -> build/lib/ipypublish/html/ipypublish
copying ipypublish/html/ipypublish/latex_doc.py -> build/lib/ipypublish/html/ipypublish
copying ipypublish/html/ipypublish/slides_mkdown.py -> build/lib/ipypublish/html/ipypublish
copying ipypublish/html/ipypublish/toc_sidebar.py -> build/lib/ipypublish/html/ipypublish
copying ipypublish/html/ipypublish/toggle_buttons.py -> build/lib/ipypublish/html/ipypublish
creating build/lib/ipypublish/html/standard
copying ipypublish/html/standard/__init__.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/content.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/content_tagging.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/document.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/inout_prompt.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/mathjax.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/slides.py -> build/lib/ipypublish/html/standard
copying ipypublish/html/standard/widgets.py -> build/lib/ipypublish/html/standard
creating build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/__init__.py -> build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/biblio_natbib.py -> build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/contents_framed_code.py -> build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/contents_output.py -> build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/doc_article.py -> build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/filters.py -> build/lib/ipypublish/latex/ipypublish
copying ipypublish/latex/ipypublish/front_pages.py -> build/lib/ipypublish/latex/ipypublish
creating build/lib/ipypublish/latex/standard
copying ipypublish/latex/standard/__init__.py -> build/lib/ipypublish/latex/standard
copying ipypublish/latex/standard/in_out_prompts.py -> build/lib/ipypublish/latex/standard
copying ipypublish/latex/standard/standard_article.py -> build/lib/ipypublish/latex/standard
copying ipypublish/latex/standard/standard_contents.py -> build/lib/ipypublish/latex/standard
copying ipypublish/latex/standard/standard_definitions.py -> build/lib/ipypublish/latex/standard
copying ipypublish/latex/standard/standard_packages.py -> build/lib/ipypublish/latex/standard
creating build/bdist.macosx-10.7-x86_64
creating build/bdist.macosx-10.7-x86_64/egg
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish
copying build/lib/ipypublish/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/html_ipypublish.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/html_standard.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/latex_ipypublish_main.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/latex_standard_article.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/slides_ipypublish.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
copying build/lib/ipypublish/export_plugins/slides_standard.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/html
copying build/lib/ipypublish/html/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html
copying build/lib/ipypublish/html/create_tpl.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish
copying build/lib/ipypublish/html/ipypublish/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish
copying build/lib/ipypublish/html/ipypublish/latex_doc.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish
copying build/lib/ipypublish/html/ipypublish/slides_mkdown.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish
copying build/lib/ipypublish/html/ipypublish/toc_sidebar.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish
copying build/lib/ipypublish/html/ipypublish/toggle_buttons.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/content.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/content_tagging.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/document.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/inout_prompt.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/mathjax.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/slides.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
copying build/lib/ipypublish/html/standard/widgets.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex
copying build/lib/ipypublish/latex/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex
copying build/lib/ipypublish/latex/create_tplx.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/biblio_natbib.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/contents_framed_code.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/contents_output.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/doc_article.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/filters.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
copying build/lib/ipypublish/latex/ipypublish/front_pages.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/latex/standard/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/latex/standard/in_out_prompts.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/latex/standard/standard_article.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/latex/standard/standard_contents.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/latex/standard/standard_definitions.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/latex/standard/standard_packages.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard
copying build/lib/ipypublish/main.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors
copying build/lib/ipypublish/preprocessors/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors
copying build/lib/ipypublish/preprocessors/crop_cells.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors
copying build/lib/ipypublish/preprocessors/latex_doc.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors
copying build/lib/ipypublish/preprocessors/latextags_to_html.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors
creating build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/export_plugins.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/ipynb_latex_setup.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/nbexport.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/nbmerge.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/pdfexport.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/scripts/reveal_serve.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts
copying build/lib/ipypublish/test_main.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish
copying build/lib/ipypublish/utils.py -> build/bdist.macosx-10.7-x86_64/egg/ipypublish
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/html_ipypublish.py to html_ipypublish.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/html_standard.py to html_standard.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/latex_ipypublish_main.py to latex_ipypublish_main.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/latex_standard_article.py to latex_standard_article.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/slides_ipypublish.py to slides_ipypublish.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/export_plugins/slides_standard.py to slides_standard.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/create_tpl.py to create_tpl.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish/latex_doc.py to latex_doc.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish/slides_mkdown.py to slides_mkdown.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish/toc_sidebar.py to toc_sidebar.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/ipypublish/toggle_buttons.py to toggle_buttons.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/content.py to content.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/content_tagging.py to content_tagging.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/document.py to document.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/inout_prompt.py to inout_prompt.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/mathjax.py to mathjax.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/slides.py to slides.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/html/standard/widgets.py to widgets.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/create_tplx.py to create_tplx.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/biblio_natbib.py to biblio_natbib.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/contents_framed_code.py to contents_framed_code.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/contents_output.py to contents_output.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/doc_article.py to doc_article.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/filters.py to filters.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/ipypublish/front_pages.py to front_pages.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard/in_out_prompts.py to in_out_prompts.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard/standard_article.py to standard_article.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard/standard_contents.py to standard_contents.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard/standard_definitions.py to standard_definitions.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/latex/standard/standard_packages.py to standard_packages.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/main.py to main.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors/crop_cells.py to crop_cells.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors/latex_doc.py to latex_doc.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/preprocessors/latextags_to_html.py to latextags_to_html.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/export_plugins.py to export_plugins.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/ipynb_latex_setup.py to ipynb_latex_setup.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/nbexport.py to nbexport.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/nbmerge.py to nbmerge.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/pdfexport.py to pdfexport.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/reveal_serve.py to reveal_serve.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/test_main.py to test_main.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/ipypublish/utils.py to utils.pyc
creating build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
installing scripts to build/bdist.macosx-10.7-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/nbpublish -> build/scripts-2.7
copying and adjusting bin/nbpresent -> build/scripts-2.7
changing mode of build/scripts-2.7/nbpublish from 644 to 755
changing mode of build/scripts-2.7/nbpresent from 644 to 755
creating build/bdist.macosx-10.7-x86_64/egg/EGG-INFO/scripts
copying build/scripts-2.7/nbpresent -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO/scripts
copying build/scripts-2.7/nbpublish -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.macosx-10.7-x86_64/egg/EGG-INFO/scripts/nbpresent to 755
changing mode of build/bdist.macosx-10.7-x86_64/egg/EGG-INFO/scripts/nbpublish to 755
copying ipypublish.egg-info/PKG-INFO -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying ipypublish.egg-info/SOURCES.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying ipypublish.egg-info/dependency_links.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying ipypublish.egg-info/requires.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying ipypublish.egg-info/top_level.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying ipypublish.egg-info/zip-safe -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
creating dist
creating 'dist/ipypublish-0.3.2-py2.7.egg' and adding 'build/bdist.macosx-10.7-x86_64/egg' to it
removing 'build/bdist.macosx-10.7-x86_64/egg' (and everything under it)
Processing ipypublish-0.3.2-py2.7.egg
Copying ipypublish-0.3.2-py2.7.egg to /Users/user/anaconda2/lib/python2.7/site-packages
Removing ipypublish 0.3.2 from easy-install.pth file
Adding ipypublish 0.3.2 to easy-install.pth file
Installing nbpresent script to /Users/user/anaconda2/bin
Installing nbpublish script to /Users/user/anaconda2/bin

Installed /Users/user/anaconda2/lib/python2.7/site-packages/ipypublish-0.3.2-py2.7.egg
Processing dependencies for ipypublish==0.3.2
. . .

Finished processing dependencies for ipypublish==0.3.2
$ pip list | grep pub
ipypublish (0.3.2, /Users/user/anaconda2/lib/python2.7/site-packages/ipypublish-0.3.2-py2.7.egg)

Running

$ nbpublish -pdf Untitled.ipynb 
Traceback (most recent call last):
  File "/Users/user/anaconda2/bin/nbpublish", line 4, in <module>
    __import__('pkg_resources').run_script('ipypublish==0.3.2', 'nbpublish')
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pkg_resources/__init__.py", line 741, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1509, in run_script
    exec(script_code, namespace, namespace)
  File "/Users/user/anaconda2/lib/python2.7/site-packages/ipypublish-0.3.2-py2.7.egg/EGG-INFO/scripts/nbpublish", line 4, in <module>
    __import__('pkg_resources').run_script('ipypublish==0.3.2', 'nbpublish')
  File "build/bdist.macosx-10.7-x86_64/egg/ipypublish/main.py", line 19, in <module>
  File "build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/export_plugins.py", line 117, in <module>
  File "build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/export_plugins.py", line 99, in add_directory
  File "build/bdist.macosx-10.7-x86_64/egg/ipypublish/scripts/export_plugins.py", line 63, in _get_modules
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pathlib.py", line 997, in glob
    for p in selector.select_from(self):
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pathlib.py", line 493, in _select_from
    if not is_dir(parent_path):
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pathlib.py", line 1188, in is_dir
    return S_ISDIR(self.stat().st_mode)
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pathlib.py", line 1051, in stat
    return self._accessor.stat(self)
  File "/Users/user/anaconda2/lib/python2.7/site-packages/pathlib.py", line 346, in wrapped
    return strfunc(str(pathobj), *args)
OSError: [Errno 20] Not a directory: '/Users/user/anaconda2/lib/python2.7/site-packages/ipypublish-0.3.2-py2.7.egg/ipypublish/export_plugins'

pathlib dependency?

I notice that pathlib 1.0.1 is given as a dependency. pathlib is is maintenance-only mode and no longer tracks python 3's pathlib. The preferred backbork of pathib to python 2 is pathlib2. Is there a particular reason to prefer pathlib, or should I prepare a patch

Improve slides

  • There is another package nbpresent so maybe I should change the command name to avoid conflict.
  • it outputs "output_type": "stream" in a weird position (could be a problem for html_ipypublish as well)
  • remove specific first_cell tag and handle this in the jinja tamplate
  • title page from latex_docs information
  • add fragments options
    NB: this could be an issue with the SplitOutputs preprocessor
  • better control of individual slide content (currently just splits out headers and sub-headers)
  • auto-number headings
    have this working for h1 but always seems to mess up when attempting lower levels like this
  • outline of sections on left and/or first slide, with faded text for everything but current section
    maybe this: https://github.com/frederickf/presentable/wiki/For-reveal.js
  • captions from cells
  • code cells (and captions)
  • figure/table/equation numbering (that matches references)
  • links in slides don't work (but do in normal html)
    asked about it here: https://stackoverflow.com/questions/45160379/how-to-make-internal-links-work-in-reveal-js-slides
  • handle adding reveal.js plugins (inject them into the code or copy them next to output)
    do you have to specify dependancy src as file path?
  • nicer css?

There is also an open ticket in jupyter/nbconvert#612

Improve End User Experience

Resulting from discussion in #27 (and #26)

  • make a latex_ipypublish_draft plugin, with all output put in the pdf by default. The only downside of such a document is that you wouldn't have a nice caption under the plot or label (to reference the plot in other parts of the document). Have this as default, or override current default by use of config file (see #13)
  • it might be good to have a specific check for .tex files output with nothing between the \begin{document} and \end{document} and output a specific warning in the log.
  • also in the log, it would be good for it to give a summary/verbose output of what cells it is outputting to the document and which it is ignoring, to avoid this kind of confusion.
  • put in the documentation about accessing metadata (View/Cell Toolbar/Edit Metadata) c4b569c
  • remove --pdf-debug tag and, instead set pdf_debug=True if --log-level is set to debug (and change raised Error message in pdfexport)

slide reference hyperlinks

  1. references in captions need to be given correct links
  2. the row number works for code floats but not figures, can't see why
    Could even think about redoing this completely

Support raw cells

First of all, thanks for a great tool! I am currently using ipypublish for writing a textbook on "generating software tests."

One issue: nbpublish does not seem to support raw cells in documents, as nbconvert does. Sometimes, I'd like to include content that is LaTeX-only or HTML-only, which I'd put into raw cells; but nbpublish seems to ignore all "raw" content.

Set longer figure/table captions in a Markdown cell

For longer captions, It would be nice to actually see them in the Jupyter notebook.

Maybe this could be achieved by:

  1. having a markdown cell with metadata.latex_caption= pair, such that the value = label name of the figure
  2. the figure cell then having metadata.latex_table.link_caption=true
  3. in the template file (.tplx), when a markdown cell with latex_caption is found, its text is saved to a variable
  4. in the template file (.tplx) when a cell with metadata.latex_table.link_caption is found and a value exists for its figure, then that value is inserted into the caption

The issues with this are:

  • presumably the markdown cell would have to be above the figure cell
  • how to store a key:value pair in latex (or jinja)
    • converting the label to an acceptable and key format (e.g. fig:example to _fig_example)
    • ensuring the key is unique
  • how to check the key exists
  • how insert it into the caption

Store Variable

\newcommand{\newCommandName}{text to insert} or \savebox

See https://stackoverflow.com/questions/1211888/is-there-any-way-i-can-define-a-variable-in-latex and https://tex.stackexchange.com/questions/655/what-is-the-difference-between-def-and-newcommand

Maybe use \detokenize{label} for acceptable key format (https://tex.stackexchange.com/a/48931/107738)

Key Exists

\ifdefined\variable
 \variable
\else
Oops.
\fi

See https://tex.stackexchange.com/a/28672/107738

Insert into Caption

Will probably have to use \caption{\protect\variable} (see https://tex.stackexchange.com/a/207917/107738)

Multiple output formats and passing `metadata` to the `display` function

Hello Chris,
I saw some of the updates in the documentation. Good to have more info.

I am having some problems and maybe it is documented but I could not make it work still.

Below are some text and a test notebook to show what I am doing.

Problem

  • This is more related with LaTeX but even using "placement": "H" does not force the elements to appear in the proper sequence. This could be related to the processing of an unordered list or dictionary.
  • There is no caption for the table.

Trying to force a ToC

There should be a ToC

  • ToC is NOT present with the default style.
  • ToC IS present with the -f latex_ipypublish_nocode
  • The ToC should include tables
  • The ToC should include figures

Thanks and Regards,
Angelo

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data quality\n",
    "High-quality data needs to pass a set of quality criteria. Those include:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# libraries\n",
    "import re\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "pd.set_option('display.precision', 10)\n",
    "\n",
    "from IPython.display import display\n",
    "from IPython.display import Markdown\n",
    "\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "plt.ioff()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def to_markdown(df):\n",
    "    \n",
    "    # column alignment convertion from latex to markdown\n",
    "    col_align = {'l': u':--', 'c': u':-:', 'r': u'--:'}\n",
    "    \n",
    "    # if is a dataframe convert to the latex representation\n",
    "    if isinstance(df, pd.DataFrame):\n",
    "        table = df.to_latex(index=False)\n",
    "    else:\n",
    "        table = df\n",
    "    \n",
    "    # break by lines\n",
    "    table = table.split(u'\\n')\n",
    "    \n",
    "    # get the header formating\n",
    "    header = re.findall(u'\\\\\\\\begin{tabular}{([lcr]*)}', table[0])\n",
    "    # should find just one\n",
    "    header = header[0]\n",
    "    # convert from latex to markdown\n",
    "    header = [col_align[c] for c in header]\n",
    "    # put it together\n",
    "    header = u'|'.join(header) + u'\\\\\\\\'\n",
    "    # update the table\n",
    "    table[3] = header\n",
    "    # get rid of the extras at the top and bottom\n",
    "    table = table[2:-3]\n",
    "    # add '|' on the extremes and an \\n\n",
    "    table = [u'|{}|\\n'.format(re.sub(u' & ', u'|', t)[:-2]) for t in table]\n",
    "    table = u''.join(table)\n",
    "    \n",
    "    return table"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "columns = {'balance_amt': np.int64}\n",
    "\n",
    "df = pd.DataFrame({'balance_amt': np.array([1000*np.random.rand() for _ in range(500)])})\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "tb = pd.DataFrame({'A': [i for i in range(65, 70)],\n",
    "                   'B': [chr(i) for i in range(65, 70)]})\n",
    "tb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Problem\n",
    "- This is more related with LaTeX but even using `\"placement\": \"H\"` does not force the elements to apper in the proper sequence. This could be related to the processing of an unordered list or dictionary.\n",
    "- There is no `caption` for the table.\n",
    "\n",
    "## Trying to force a ToC\n",
    "### There should be a ToC\n",
    "- ToC is NOT present with the default style.\n",
    "- ToC IS present with the `-f latex_ipypublish_nocode`\n",
    "- The ToC should include tables\n",
    "- The ToC should include figures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ipub": {
     "figure": {
      "placement": "H"
     },
     "mkdown": true,
     "table": {
      "placement": "H"
     }
    }
   },
   "outputs": [],
   "source": [
    "table_count = 1\n",
    "figure_count = 1\n",
    "\n",
    "for var in columns.keys():\n",
    "    var_l = re.sub('_', '\\_', var)\n",
    "    display(Markdown('#### Describe for %s  ' % var),\n",
    "            metadata={'ipub':{'mkdown': 'true'}})\n",
    "\n",
    "    display(Markdown(to_markdown(tb.to_latex(index=False))),\n",
    "                     metadata={'ipub':{'table':{'caption':'Describe for %s  ' % var_l,'label':'table:tlabel%d' % table_count,'placement':'H'}}})\n",
    "    table_count += 1\n",
    "    \n",
    "    # histograms\n",
    "    display(Markdown('#### Histograms for `%s`  ' % var),\n",
    "            metadata={'ipub':{'mkdown':{'placement':'H'}}})\n",
    "\n",
    "    mi, ma = df[var].min(), df[var].max()\n",
    "    bin = ma - mi\n",
    "    bin = 80 if bin > 80 else bin\n",
    "    fig = plt.figure(figsize=(15, 5))\n",
    "    plt.grid(zorder=0)\n",
    "    plt.hist(df[var], bins=bin, zorder=3)\n",
    "    plt.title('%s: Histogram between %d (min) and %d (max)' % (var, mi, ma), fontsize=14)\n",
    "    plt.close()\n",
    "    display(fig, \n",
    "            metadata={'ipub':{'figure':{'caption':'Describe for %s  ' % var_l,'label':'figure:flabel%d' % figure_count,'placement':'H'}}})\n",
    "    figure_count += 1"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Edit Metadata",
  "ipub": {
   "titlepage": {
    "author": "Angelo Klin",
    "email": "[email protected]",
    "institution": [
     "Katra"
    ],
    "listcode": false,
    "listfigures": true,
    "listtables": true,
    "subtitle": "Queries",
    "supervisors": [
     "The Boss"
    ],
    "tagline": "Using data and technology to create products.",
    "title": "Data Quality",
    "toc": true
   }
  },
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

better visualising/editting of metadata attributes in the Jupyter notebook

Create a notebook extension with:

  1. A drop down box (like is available from View/Cell Toolbar/slideshow) to quickly switch on/off features, namely latex_doc.ignore
  2. It would be nice to quickly see which cells have certain metadata keys (latex_table, latex_figure, ...).

At its simplest, I could imagine typing a key name into a textbox and cells with that key present are set with a colored border, or all other cells are hidden.

More complex would be having a list of key:color pairs (stored in the notebook metadata or in jupyter_notebook_config.py), ordered by priority (i.e. if the cell has multiple metadata keys then the first one in the list is used to assign color)

{% extends 'full.tpl'%}
{% block any_cell %}
    <div style="border:thin solid red">
        {{ super() }}
    </div>
{% endblock any_cell %}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.