Skip to content

Commit

Permalink
Reproduce and fix Rmd issue in 1.3rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Nov 9, 2019
1 parent 4a02bb0 commit 17c9d34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion jupytext/cell_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ def __init__(self, fmt=None, default_language=None):
self.split_at_heading = (fmt or {}).get('split_at_heading', False)
self.in_region = False
self.in_raw = False
if self.format_version in ['1.0', '1.1']:
if self.format_version in ['1.0', '1.1'] and self.ext != '.Rmd':
# Restore the pattern used in Markdown <= 1.1
self.start_code_re = re.compile(r"^```(.*)")
self.non_jupyter_code_re = re.compile(r"^```\{")

def metadata_and_language_from_option_line(self, line):
match_region = self.start_region_re.match(line)
Expand Down
20 changes: 19 additions & 1 deletion tests/test_read_simple_rmd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from nbformat.v4.nbbase import new_markdown_cell, new_notebook
from nbformat.v4.nbbase import new_notebook, new_markdown_cell, new_code_cell
from jupytext.compare import compare, compare_notebooks
import jupytext
from .utils import skip_if_dict_is_not_ordered
Expand Down Expand Up @@ -81,3 +81,21 @@ def test_two_markdown_cell_with_code_works(nb=new_notebook(cells=[
text = jupytext.writes(nb, 'Rmd')
nb2 = jupytext.reads(text, 'Rmd')
compare_notebooks(nb2, nb)


def test_tags_in_rmd(rmd='''---
jupyter:
jupytext:
text_representation:
extension: .Rmd
format_name: rmarkdown
format_version: '1.1'
jupytext_version: 1.2.3
---
```{python tags=c("parameters")}
p = 1
```
''', nb=new_notebook(cells=[new_code_cell('p = 1', metadata={'tags': ['parameters']})])):
nb2 = jupytext.reads(rmd, 'Rmd')
compare_notebooks(nb2, nb)

0 comments on commit 17c9d34

Please sign in to comment.