'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?
Solution 1:[1]
you can embed python into .Rmd as well, see https://github.com/yihui/knitr-examples/blob/master/023-engine-python.Rmd for examples
Solution 2:[2]
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.
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ricardo Pietrobon |
| Solution 2 | Nick |
| Solution 3 | Julia Roquette |
