# [IPython-User] nbconvert converts to/from IPyNB or just from IPyNb?

Nitin Borwankar nborwankar@gmail....
Sat Feb 23 18:39:11 CST 2013

Hi Matthias,

Thanks very much for the prompt response.
Authoring my content in .rst instead of .md is not much of a burden. So I
will try that. pandoc is our friend.

Just one caveat - running nosetests on git trunk of nbconvert gave an error
that unfort. seems like it is connected with .rst --> ipynb converter.
does this affect the ability to run .rst --> ipynb?
Error Msg at the end - I don't know enough to interpret.
Could you please clarify?  I did a git pull a couple of hours ago.

Other than that - yes I have become very familiar with %%R magics over last
month or so and have even learnt how to use ggplot2 inside IPython :-).
You might recall a bug in the %R line magic I reported here a month or so
ago - thankfully %%R still works and that's what I really need so no
problems there.

The point is that I don't want to tightly couple the R snippets into the
expository content and then have to cut and paste NumPy or MATLAB or
....manually each time - a JSON object (or even text content for that
matter) is "software" and maintenance of multiple variations, with cut and
paste will create nightmares very rapidly.

The beauty of the IPyNB format is that since it is text friendly and
conversion friendly multiple variations (note variations not revisions) of
the same Notebook can be created using a single text template and varying
%%language magics injected in at build time by a command line switch.

So my goal is to have some placeholder markers in the text content where
the language magics go and have a switch at build time so one or more or
all variations can be created without cut and paste.

Right now if .rst  --> .ipynb is working (please see errors below and let
me know) then that is a good workaround. Pandoc is our good friend.

~/git/ipythongit/nbconvert(master)]\$ nosetests
.........F./Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:27:
(ERROR/3) Unknown interpreted text role "ref".
/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:48:
(ERROR/3) Unknown interpreted text role "ref".
/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:84:
(ERROR/3) Unknown interpreted text role "ref".
/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:127:
(ERROR/3) Unknown interpreted text role "ref".
/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:157:
(ERROR/3) Unknown interpreted text role "ref".
/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:157:
(ERROR/3) Unknown interpreted text role "ref".
/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/tutorial.rst.ref:190:
(ERROR/3) Unknown interpreted text role "ref".
.........
======================================================================
FAIL: test_references.test_evens(<class 'converters.html.ConverterHTML'>,
'tests/ipynbref/IntroNumPy.orig.ipynb',
'tests/ipynbref/IntroNumPy.orig.html')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Applications/anaconda/lib/python2.7/site-packages/nose/case.py",
line 197, in runTest
self.test(*self.arg)
File
"/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/test_references.py",
line 58, in test_conversion
compfiles(cv, value)
File
"/Volumes/HybridSeagate/my/code/git/ipythongit/nbconvert/tests/test_references.py",
line 48, in compfiles
cleanfile(strb))
AssertionError: Lists differ: [u'<html>', u'<head>', u'<styl... !=

First differing element 186:

Second list contains 18 additional elements.
First extra element 29165:
<p>IPython will start a process that runs a web server in your local
machine and to which a web browser can connect.  The Notebook is a
workspace that lets you execute code in blocks called 'cells' and displays
any results and figures, but which can also contain arbitrary text
(including LaTeX-formatted mathematical expressions) and any rich media
that a modern web browser is capable of displaying.</p>

Diff is 1047994 characters long. Set self.maxDiff to None to see it.

----------------------------------------------------------------------
Ran 20 tests in 6.368s

FAILED (failures=1)

------------------------------------------------------------------
Nitin Borwankar
nborwankar@gmail.com

On Sat, Feb 23, 2013 at 2:54 PM, Matthias BUSSONNIER <
bussonniermatthias@gmail.com> wrote:

> Hi Nitin,
>
> Le 23 févr. 2013 à 23:24, Nitin Borwankar a écrit :
>
> > Hello all,
> >
> > Sorry if this is a really dumb question and/or a FAQ.
> >
> > First some context to avoid the inevitable - "what are you really trying
> to do?"
> >
> > I have a small amount of funding to create educational content in data
> science in open formats and free licenses so as to be re-usable and
> mashable by the Internet community.
> >
> > I would like to author most of my non-code content in vanilla Markdown
> or Asciidoc in a text editor first. I would like to then "import into" or
> "convert to" IPy NBk so as to then do further authoring and testing of the
> inline code.
> >
> > I need to take existing Markdown and convert it TO IPython format.
> >
> > The Readme for nbconvert says it converts to/from but the examples and
> usage only shows *from* IPython to others.  I need the other way around.
>
> Yes, the nbconvert repository is made to contain both convert To and From
> ipynb, right now we are mostly focused on from,
> The only To converter is  rst2ipynb.py (so dealing with rst...), there is
> the .py to ipynb but this one is of the "put everything in one code cell"
> type.
>
> I don't have knowledge of the other script that generate IPynb files,
> except copy/pasting.
>
>
> > For obvious reasons there is a need, in this scenario, to convert the
> initial Markdown to multiple formats using pandoc (HTML, PDF, Slidey, ...).
> > Most of these will be exposition of the subject and will not contain
> live code.  The Notebook format will be for exercises injected into the
> content.
> >
> > Another need is to keep example code modular and decoupled from the
> content so as to be able to plug in R exercises or NumPy exercises or even
> MATLAB exercises via a build tool depending on user need.
>
> What you describe would also look like knitr [1] is doing (haven't tried
> it though), and I think converter knitr <-> ipynb would be great.
> There is also the %%R and %%matlab magic :-)
>
> > Questions
> >
> > a) forgetting my eventual goal - if I just have some Markdown can I
> convert to IPy Nbk easily - are there some tools - am I missing something
>
> Right now, there is no tool, but it shouldn't be too hard. The most
> difficult would be to define cell "delimiters". (I guess those can be
> "In[*]" and "Out[*]" in some cases)
>
> > b) if my Markdown contains inline latex markup are there additional
> requirements other than making sure mathjax etc is in the browser
> environment.
>
> None that I can see. Even if mathjax can't deal with it, it won't
> **break** the notebook. it will just display the raw tex.
>
> > Thanks much and sorry again if this is a FAQ.
> No problem, this is not a frequently asked question, there is just so much
> to do that we can't fight on all front !
> Keep us posted if you want to try to work a md->ipynb converter, and don't
>
> I opened an issue to track this [2]
>
> --
> Matthias
>
> [1]: http://yihui.name/knitr/
> [2]: https://github.com/ipython/nbconvert/issues/96
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130223/0e5e9139/attachment-0001.html