user1335014
user1335014

Reputation: 431

Is there a way to add embedded python code to Markdown?

There is a way to add R code to Markdown (Rmd) by using

```{r}
foo()
```

The result will be shown as a block of code and the output of that code (that will be calculated dynamically).

Can the same thing be done for Python or for that matter any other language?

Upvotes: 14

Views: 39273

Answers (3)

Julia Roquette
Julia Roquette

Reputation: 696

you can simply use:

```python 
your_code = do_some_stuff
```

And yes, you can do the same for a long list of languages. You can check the list of languages supported in this link: https://rdmd.readme.io/docs/code-blocks

Upvotes: 17

Nick
Nick

Reputation: 21

marky is Markdown preprocessor allowing to execute embedded python code in Markdown documents. Documents are rendered in pdf and html using pandoc. All steps are implemented in a Makefile.

Upvotes: 2

Ricardo Pietrobon
Ricardo Pietrobon

Reputation: 858

you can embed python into .Rmd as well, see https://github.com/yihui/knitr-examples/blob/master/023-engine-python.Rmd for examples

Upvotes: 3

Related Questions