Open yuvipanda opened 3 years ago
In part this makes me think of https://stackoverflow.com/questions/28972614/jupyter-ipython-notebook-convert-an-html-notebook-to-ipynb/47138762#47138762, which converts notebooks previewed as HTML in some conventional way back to ipynb
.
I don't know if the .Rmd
HTML outputter has a regular structure that could be parsed back into basic .ipynb
doc somehow (assumptions may be required!) If nothing else, I guess you could just convert the html to .md
and then run it through Jupytext to .ipynb
? Not sure how brittle this would be though.
Ideally, though, there'd be some sort of rich Rmd that could capture an equivalent of .ipynb
code output cell, though it's not clear how eg RStudio would render it?
RStudio must internally have some sort of notion of a code output cell when you work with Rmd in an interactive way in RStudio, and a way of persisting it, even if only in an embedded display way. Eg I just opened a previously closed project in RStudio and the output from previously interactively run cells in an Rmd doc (in this case, a table, but it could be an image or an embedded html widget etc) is still there:
The typical workflow for 'publishing' .Rmd files is (very, very roughly):
knit
it. This will run the code in the file, and generate non-inline outputs, in a directory nearbyknitr
can then render your code + output files into a self-contained, such as HTML. Images are inlined as data attributes, etc.For a similar experience as ipynb files, we want to get rendered .Rmd files, rather than just the code as we do now.
There are a few options here:
I spent some time working on (2). Since pandoc now has support for
ipynb
, and rmarkdown uses pandoc for all conversions, it should theoretically be easy to make this. However, for export to ipynb, pandoc expects code blocks to be:while the intermediate .md produced by rmarkdown is like:
This is valid pandoc markdown, but pandoc particularly seems to want the code fence to have
code
to denote ipynb code cell rather than the more specific{ .r}
.However, thinking about this some more, (1) is clearly the more 'first class' R experience.