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

Matthias BUSSONNIER bussonniermatthias@gmail....
Sat Feb 23 16:54:43 CST 2013

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 about nbconvert usage?

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 hesitate to ask for help / advices.

I opened an issue to track this [2]

--
Matthias

[1]: http://yihui.name/knitr/
[2]: https://github.com/ipython/nbconvert/issues/96