39

People who work with R are undoubtedly familiar with the R markdown package.

I am a vivid python user and use Mistune for converting markdown to html pages. It also supports code highlighting and mathjax to embed latex formulas in html. However there's one type of functionality missing.

R markdown has the possibility of executing R code inline (and rendering the result to html) or rendering graphs inline. That saves time and makes the documentation maintainable as you don't need to manually prepare the output of that function or manually prepare and save a graph since it's rendered on the fly.

Is there such a possibility or library in python, perhaps in combination with Mistune?

Tim
  • 2,000
  • 4
  • 27
  • 45
  • 10
    Now Python can be used in Rmarkdown docs: https://rmarkdown.rstudio.com/authoring_knitr_engines.html#overview – byouness May 05 '18 at 22:20
  • 1
    Just came across [quarto](https://quarto.org/), which seems to be targeting this very issue and has similar syntax to Rmarkdown but works across a few languages and can be added into a few of the popular IDEs (VS code, RStudio, jupyter, basic text editor) – Joseph Crispell Aug 05 '22 at 12:49

1 Answers1

15

You should really check out ipython notebook (now it's called Jupyter because it supports many languages including R), it can be a little difficult to install for those beginning with Python, so I might also suggest the Anaconda Python Distribution which includes it by default.

allows you to execute code, enter markdown formatted text, display graphs and much much more.

iLoveTux
  • 3,552
  • 23
  • 31
  • 2
    This looks like exactly what I need. Can it export the endresult to a standalone html so other users won't need to rely on an installation of notebook/python to view the documentation? – Tim Oct 14 '15 at 07:10
  • Yes it can export to html, pdf, python source and REStructuredText. – iLoveTux Oct 14 '15 at 07:12
  • 1
    Also have a look at jupinx: https://medium.com/quantecon-blog/introducing-jupinx-60ba9fc12f4f . It converts REStructuredText into jupyter notebooks. – asmaier May 11 '18 at 09:50
  • 35
    Notebooks while indispensable are not the same as `rmarkdown` in which the entire structure fits within a standard editor. A few of us prefer initial large-scale editing to happen _not_ within the notebook editor environment. – WestCoastProjects Nov 23 '18 at 02:18
  • 2
    just noticed the post by @asmaier about `jupinx` : you should actually make that a new answer: I for one would upvote it – WestCoastProjects Nov 23 '18 at 02:21
  • @WestCoastProjects the Jupytext extension helps converging jupyter notebooks (which are html files with large blobs including graphical and other outputs) to markdown files containing text and source code on the fly. A markdown version is very useful to archive the notebooks in git and diff them. – Paul Rougieux Sep 02 '21 at 09:56