Skip to content

Commit

Permalink
Sample Markdown file
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Mar 30, 2019
1 parent ad2134d commit f9616bc
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/notebooks/md/jupytext_markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
jupyter:
kernelspec:
display_name: Python 3
language: python
name: python3
---

# Markdown, code and raw cells

## Markdown cells

This is a Markdown cell. Markdown cells end with either a code cell, or two consecutive blank lines in the text.

If you prefer that Markdown headings define new cells, have a look at the `split_at_heading` option.

Indented code is accepted, and consecutive blank lines there do not break Markdown cells:

def f(x):
return 1


def h(x):
return f(x)+2


## Code cells

```python
"""This code cell starts with ` ```python`"""
1 + 1
```

## Raw cells

Raw cells starts with ` ``` `, like here:
```
THIS IS A RAW CELL
```

# Protected Markdown cells

If you want to include code blocks (or two consecutive blank lines) in a Markdown cell, use explicit Markdown cell delimiters `<!-- #region -->` and `<!-- #endregion -->`.

<!-- #region -->
This Markdown cell has two consecutive blank lines


And then a code block which is not a Jupyter code cell:
```python
2 + 2
```
<!-- #endregion -->

# Metadata

Metadata are supported for all cell types.

## Markdown cells

<!-- #region Region title {"key": "value"} -->
A cell with a title and additional metadata.
<!-- #endregion -->

## Code and raw cells

```python tags=["parameters"]
a = 2
```
129 changes: 129 additions & 0 deletions tests/notebooks/mirror/md_to_ipynb/jupytext_markdown.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Markdown, code and raw cells\n",
"\n",
"## Markdown cells\n",
"\n",
"This is a Markdown cell. Markdown cells end with either a code cell, or two consecutive blank lines in the text.\n",
"\n",
"If you prefer that Markdown headings define new cells, have a look at the `split_at_heading` option.\n",
"\n",
"Indented code is accepted, and consecutive blank lines there do not break Markdown cells:\n",
"\n",
" def f(x):\n",
" return 1\n",
"\n",
"\n",
" def h(x):\n",
" return f(x)+2\n",
"\n",
"\n",
"## Code cells"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\"\"\"This code cell starts with ` ```python`\"\"\"\n",
"1 + 1"
]
},
{
"cell_type": "markdown",
"metadata": {
"lines_to_next_cell": 0
},
"source": [
"## Raw cells\n",
"\n",
"Raw cells starts with ` ``` `, like here:"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"THIS IS A RAW CELL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Protected Markdown cells\n",
"\n",
"If you want to include code blocks (or two consecutive blank lines) in a Markdown cell, use explicit Markdown cell delimiters `<!-- #region -->` and `<!-- #endregion -->`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This Markdown cell has two consecutive blank lines\n",
"\n",
"\n",
"And then a code block which is not a Jupyter code cell:\n",
"```python\n",
"2 + 2\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Metadata\n",
"\n",
"Metadata are supported for all cell types.\n",
"\n",
"## Markdown cells"
]
},
{
"cell_type": "markdown",
"metadata": {
"key": "value",
"title": "Region title"
},
"source": [
"A cell with a title and additional metadata."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Code and raw cells"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"a = 2"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
5 changes: 5 additions & 0 deletions tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ def test_sphinx_md_to_ipynb(nb_file):
'sphinx-rst2md_to_ipynb', compare_notebook=True)


@pytest.mark.parametrize('nb_file', list_notebooks('md'))
def test_md_to_ipynb(nb_file):
assert_conversion_same_as_mirror(nb_file, 'ipynb', 'md_to_ipynb')


@pytest.mark.parametrize('nb_file', list_notebooks('Rmd'))
def test_Rmd_to_ipynb(nb_file):
assert_conversion_same_as_mirror(nb_file, 'ipynb', 'Rmd_to_ipynb')
Expand Down

0 comments on commit f9616bc

Please sign in to comment.