Python function to split markdown code

Job ID: 36421597

Budget: €8 – €30 EUR

I want a small Python function split_markdown() to split an RMarkdown code into chapters.

Example code:

```
# This is a level 1 heading

Some text goes here.

## This is a level 2 heading

Some more text goes here. Here comes some code:

```{python}
# This is code
a = 4
a + 6 # do some calculation
```

This is a heading
=================

Even more text here.
```

Desired output: a list with three elements:
["# This is a level 1 heading

Some text goes here.

",
"## This is a level 2 heading

Some more text goes here. Here comes some code:

```{python}
# This is code
a = 4
a + 6 # do some calculation
```

",
"This is a heading
=================

Even more text here."]

It should work also for more complicated RMarkdown files.
Related categories: Python Regular Expressions