jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.74k stars 568 forks source link

Feature request: polished reports via pandoc #987

Closed kkmann closed 2 years ago

kkmann commented 5 years ago

Hey,

I must say that I am a big fan of the jupyter notebook and what it has done to promote enjoyable literate programming over the past years. However, I still mostly used R Markdown + knitr to script my analyses and get polished reports out. It is just so convenient to have the full power of pandoc, native support for code cell hiding, and markdown output of tables via 'knitr::kable' and the like. Turning an .Rmd file in a polished pdf or html report is just sooo easy. The yaml header adds so much flexibility and even referencing from a .bib file is super easy. My main problem with R Markdown is that the 'notebook version' is not really working that well since the interactive mode only works with R Studio and the interface is much more cluttered than a nice, clean jupyter lab or notebook!

So, I really wonder whether there is any effort in terms of providing similar 'publication quality reporting' capabilities to jupyter notebooks? I mean, it should be fairly straight forward to include a yaml header cell type that get displayed in a nice way in the notebook itself (not as markdown ;)) and simply gets written to .md verbatim (skipped for all other formats). Is there any hope for getting support for references using .bib files (again working both for the notebook itself and a .md export) or even cross-referencing of outputs? I would just love to interactively develop a manuscript submission as jupyter notebook and then simply add a proper yaml header, export to .md, and get a polished submittable manuscript via pandoc (pdf/html/or even .docx).

Not quite sure whether this is the right place to raise this, but the issues seems to affect both nbconvert and the notebook format. Not quite sure what the best technical way of implementing this would be.

mgeier commented 5 years ago

Some of your requests can be achieved with nbsphinx: https://nbsphinx.readthedocs.io/ (full disclosure: I'm the author).

Code cell hiding is not yet supported, but it is oft-requested (e.g. https://github.com/spatialaudio/nbsphinx/issues/15, https://github.com/spatialaudio/nbsphinx/issues/65, https://github.com/spatialaudio/nbsphinx/pull/86, https://github.com/spatialaudio/nbsphinx/pull/185).

Referencing with .bib files works: https://nbsphinx.readthedocs.io/en/0.4.2/markdown-cells.html#Citations.

Cross-referencing between notebooks also works: https://nbsphinx.readthedocs.io/en/0.4.2/markdown-cells.html#Links-to-Other-Notebooks.

Supported output formats are HTML, LaTeX and EPUB. Here's an example for PDF output: https://readthedocs.org/projects/nbsphinx/downloads/pdf/0.4.2/.

MSeal commented 5 years ago

To add and weight in about the new cell type question, you may want to open the discussion on https://discourse.jupyter.org or in the format repo https://github.com/jupyter/nbformat/issues as adding new cell types would likely be a 5.x+ feature change for nbformat of the schema.

On code cell hiding https://github.com/jupyter/nbformat/blob/master/nbformat/v4/nbformat.v4.schema.json has support for source_hidden, though the UIs have been mostly on 4.2 format. There's some recent pushes to fill in gaps to 4.4 where these features exist. I believe nteract UI supports it and lab UI has it PR'd / soon to release (need to check on that).