R works, of course.

library(knitr)
set.seed(123)
rnorm(5)

Does knitr work with Python? Use the chunk option engine='python':

x = 'hello, python world!'
print(x)
print(x.split(' '))

Or use the syntax ```{python}:

x = 'hello, python world!'
print(x.split(' '))

If all the chunks below are python chunks, we can set the engine globally:

opts_chunk$set(engine = 'python')

Chunk Options

You can use some chunk options like eval, echo and results. For example, eval=FALSE (do not evaluate code):


or echo=FALSE (hide source code):


or results='hide':


or results='asis':

print('**Write** _something_ in `Markdown` from `Python`!')

You can also cache the computation:

import time
# pretend this is a time-consuming task...
time.sleep(10)
print(1+1)

Strict Markdown

You can use strict markdown (i.e. indent by 4 spaces) by setting render_markdown(TRUE).

render_markdown(TRUE)

Now see how the output is changed:




Try the parsermd package in your browser

Any scripts or data that you put into this service are public.

parsermd documentation built on May 29, 2024, 6:39 a.m.